diff --git a/packages/google-cloud-servicedirectory/.eslintignore b/packages/google-cloud-servicedirectory/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-servicedirectory/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-servicedirectory/.eslintrc.json b/packages/google-cloud-servicedirectory/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-servicedirectory/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-servicedirectory/README.md b/packages/google-cloud-servicedirectory/README.md index c50971627147..42bb7e020ace 100644 --- a/packages/google-cloud-servicedirectory/README.md +++ b/packages/google-cloud-servicedirectory/README.md @@ -131,7 +131,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-servicedirectory/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`) @@ -141,7 +141,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-servicedirectory/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-servicedirectory/protos/protos.d.ts b/packages/google-cloud-servicedirectory/protos/protos.d.ts index f1b888d2baee..144c7030bdd6 100644 --- a/packages/google-cloud-servicedirectory/protos/protos.d.ts +++ b/packages/google-cloud-servicedirectory/protos/protos.d.ts @@ -6493,6 +6493,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -6510,6 +6513,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 @@ -7210,6 +7216,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -7224,6 +7233,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 @@ -7302,6 +7314,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 { @@ -7628,6 +7752,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -7642,6 +7769,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 @@ -7966,6 +8096,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, @@ -8082,6 +8315,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -8112,6 +8346,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -8161,6 +8398,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -8295,6 +8535,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -8336,6 +8579,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 @@ -9183,6 +9429,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -9209,6 +9458,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 @@ -10143,6 +10395,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); @@ -10198,6 +10453,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[]; @@ -10418,6 +10676,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. */ @@ -10656,6 +11029,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -10678,6 +11054,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[]; @@ -11267,6 +11646,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. */ @@ -11296,6 +11681,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 @@ -11418,6 +11809,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. */ @@ -11537,8 +12038,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. */ @@ -11553,8 +12057,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. @@ -12087,6 +12594,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-servicedirectory/protos/protos.js b/packages/google-cloud-servicedirectory/protos/protos.js index 8de2ee233ef9..10d4a72d883a 100644 --- a/packages/google-cloud-servicedirectory/protos/protos.js +++ b/packages/google-cloud-servicedirectory/protos/protos.js @@ -14955,6 +14955,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -14989,6 +14990,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 @@ -15021,6 +15030,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; }; @@ -15072,6 +15083,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; @@ -15123,6 +15138,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; }; @@ -15165,6 +15185,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; }; @@ -15183,8 +15208,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) { @@ -15192,6 +15219,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; }; @@ -17014,6 +17043,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -17039,6 +17069,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 @@ -17065,6 +17103,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; }; @@ -17105,6 +17145,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; @@ -17145,6 +17189,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; }; @@ -17165,6 +17214,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; }; @@ -17181,10 +17235,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; }; @@ -17214,6 +17272,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; })(); @@ -18090,6 +18400,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -18101,6 +18412,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) @@ -18115,6 +18427,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 @@ -18141,6 +18461,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; }; @@ -18171,7 +18494,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) @@ -18181,6 +18504,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; @@ -18221,6 +18567,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; }; @@ -18241,6 +18595,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; }; @@ -18257,10 +18618,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; }; @@ -18899,30 +19268,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; @@ -19168,6 +19782,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 @@ -19182,6 +19797,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; @@ -19206,6 +19822,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 @@ -19228,6 +19845,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -19278,6 +19896,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 @@ -19399,6 +20025,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; }; @@ -19471,6 +20100,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 = []; @@ -19573,6 +20208,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"; @@ -19627,6 +20269,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -19679,6 +20322,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"); @@ -19742,6 +20392,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -19807,6 +20461,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -19863,6 +20518,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; }; @@ -19911,6 +20571,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 */ /** @@ -20016,6 +20677,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 @@ -20068,6 +20737,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; }; @@ -20160,6 +20831,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -20273,6 +20948,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; }; @@ -20372,6 +21056,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; }; @@ -20401,6 +21105,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; @@ -20446,6 +21151,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; }; @@ -22490,6 +23197,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 */ /** @@ -22550,6 +23258,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 @@ -22587,6 +23303,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; }; @@ -22649,6 +23367,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -22717,6 +23439,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; }; @@ -22766,6 +23497,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; }; @@ -22790,6 +23541,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; @@ -22810,6 +23562,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; }; @@ -25128,6 +25882,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 @@ -25248,6 +26003,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 @@ -25322,6 +26085,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(); @@ -25423,6 +26188,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 = []; @@ -25558,6 +26327,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"; @@ -25746,6 +26520,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"); @@ -25843,6 +26622,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")) @@ -25875,6 +26655,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) @@ -26147,6 +26929,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26188,103 +26971,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; @@ -26879,6 +28148,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 */ @@ -26922,6 +28192,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 @@ -26960,6 +28238,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(); @@ -27011,6 +28291,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 = []; @@ -27063,6 +28347,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"; @@ -27096,6 +28385,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"); @@ -27128,6 +28422,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -27135,6 +28430,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) @@ -28574,6 +29871,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 */ /** @@ -28639,6 +29938,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 @@ -28675,6 +29990,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; }; @@ -28735,6 +30054,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; @@ -28825,6 +30152,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; }; @@ -28964,6 +30311,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; }; @@ -28987,6 +30382,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; @@ -29000,6 +30397,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; }; @@ -29127,6 +30528,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; })(); @@ -29311,6 +30925,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29328,6 +30943,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29376,6 +30992,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -29428,6 +31048,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -29536,7 +31160,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 */ /** @@ -29563,12 +31188,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. @@ -29594,10 +31227,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; }; @@ -29638,8 +31273,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: @@ -29682,6 +31321,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -29694,10 +31334,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; }; @@ -29725,6 +31370,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -29766,10 +31415,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; }; @@ -29788,13 +31442,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; }; @@ -31009,6 +32666,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-servicedirectory/protos/protos.json b/packages/google-cloud-servicedirectory/protos/protos.json index 3b80a35afa12..08ea7e5f5db5 100644 --- a/packages/google-cloud-servicedirectory/protos/protos.json +++ b/packages/google-cloud-servicedirectory/protos/protos.json @@ -1900,8 +1900,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": { @@ -2124,6 +2123,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -2264,6 +2267,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 + } + } } } }, @@ -2321,6 +2346,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -2382,6 +2412,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -2415,12 +2458,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, @@ -2459,6 +2509,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -2547,6 +2602,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2772,6 +2831,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2822,7 +2885,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2986,6 +3056,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -3121,7 +3192,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -3149,6 +3221,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3218,6 +3294,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 + } + } } } }, @@ -3306,6 +3402,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3448,6 +3548,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -3458,6 +3559,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -3468,6 +3570,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3478,6 +3581,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3488,7 +3592,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" } }, @@ -3498,27 +3603,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, @@ -3563,7 +3679,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -3578,6 +3700,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 + } + } + } } } }, @@ -3605,11 +3754,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -3622,6 +3786,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3707,6 +3877,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3749,13 +3927,13 @@ "nested": { "v1": { "options": { - "cc_enable_arenas": true, "csharp_namespace": "Google.Cloud.Iam.V1", "go_package": "cloud.google.com/go/iam/apiv1/iampb;iampb", "java_multiple_files": true, "java_outer_classname": "PolicyProto", "java_package": "com.google.iam.v1", - "php_namespace": "Google\\Cloud\\Iam\\V1" + "php_namespace": "Google\\Cloud\\Iam\\V1", + "cc_enable_arenas": true }, "nested": { "IAMPolicy": { diff --git a/packages/google-cloud-servicedirectory/samples/generated/v1/snippet_metadata_google.cloud.servicedirectory.v1.json b/packages/google-cloud-servicedirectory/samples/generated/v1/snippet_metadata_google.cloud.servicedirectory.v1.json index e5e4b2ea27fc..20a237455f5e 100644 --- a/packages/google-cloud-servicedirectory/samples/generated/v1/snippet_metadata_google.cloud.servicedirectory.v1.json +++ b/packages/google-cloud-servicedirectory/samples/generated/v1/snippet_metadata_google.cloud.servicedirectory.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-servicedirectory", - "version": "6.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-servicedirectory/samples/generated/v1beta1/snippet_metadata_google.cloud.servicedirectory.v1beta1.json b/packages/google-cloud-servicedirectory/samples/generated/v1beta1/snippet_metadata_google.cloud.servicedirectory.v1beta1.json index 2d6593f49c6e..1290d6142a6c 100644 --- a/packages/google-cloud-servicedirectory/samples/generated/v1beta1/snippet_metadata_google.cloud.servicedirectory.v1beta1.json +++ b/packages/google-cloud-servicedirectory/samples/generated/v1beta1/snippet_metadata_google.cloud.servicedirectory.v1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-servicedirectory", - "version": "6.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-servicedirectory/src/v1/index.ts b/packages/google-cloud-servicedirectory/src/v1/index.ts index e07a321f9339..0f60415e91f2 100644 --- a/packages/google-cloud-servicedirectory/src/v1/index.ts +++ b/packages/google-cloud-servicedirectory/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LookupServiceClient} from './lookup_service_client'; -export {RegistrationServiceClient} from './registration_service_client'; +export { LookupServiceClient } from './lookup_service_client'; +export { RegistrationServiceClient } from './registration_service_client'; diff --git a/packages/google-cloud-servicedirectory/src/v1/lookup_service_client.ts b/packages/google-cloud-servicedirectory/src/v1/lookup_service_client.ts index 3b1bbc86860e..c05a2bc077c0 100644 --- a/packages/google-cloud-servicedirectory/src/v1/lookup_service_client.ts +++ b/packages/google-cloud-servicedirectory/src/v1/lookup_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class LookupServiceClient { 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('service-directory'); @@ -57,10 +64,10 @@ export class LookupServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - lookupServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + lookupServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LookupServiceClient. @@ -101,21 +108,42 @@ export class LookupServiceClient { * const client = new LookupServiceClient({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 LookupServiceClient; - 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 = 'servicedirectory.' + 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 +168,7 @@ export class LookupServiceClient { 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 +182,11 @@ export class LookupServiceClient { } 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,20 +208,23 @@ export class LookupServiceClient { // Create useful helper objects for these. this.pathTemplates = { endpointPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}', ), namespacePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}' + 'projects/{project}/locations/{location}/namespaces/{namespace}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.servicedirectory.v1.LookupService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.servicedirectory.v1.LookupService', + 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 @@ -228,36 +255,40 @@ export class LookupServiceClient { // Put together the "service stub" for // google.cloud.servicedirectory.v1.LookupService. this.lookupServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.servicedirectory.v1.LookupService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.servicedirectory.v1.LookupService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.servicedirectory.v1.LookupService, - 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 lookupServiceStubMethods = - ['resolveService']; + const lookupServiceStubMethods = ['resolveService']; for (const methodName of lookupServiceStubMethods) { const callPromise = this.lookupServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -272,8 +303,14 @@ export class LookupServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -284,8 +321,14 @@ export class LookupServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -316,9 +359,7 @@ export class LookupServiceClient { * @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; @@ -327,8 +368,9 @@ export class LookupServiceClient { * 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; @@ -339,145 +381,194 @@ export class LookupServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns a {@link protos.google.cloud.servicedirectory.v1.Service|service} and its - * associated endpoints. - * Resolving a service is not considered an active developer method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service to resolve. - * @param {number} [request.maxEndpoints] - * Optional. The maximum number of endpoints to return. Defaults to 25. - * Maximum is 100. If a value less than one is specified, the Default is used. - * If a value greater than the Maximum is specified, the Maximum is used. - * @param {string} [request.endpointFilter] - * Optional. The filter applied to the endpoints of the resolved service. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, or `annotations.` for - * map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns endpoints that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * - * `name=projects/my-project/locations/us-central1/namespaces/my-namespace/services/my-service/endpoints/ep-1` - * returns the endpoint that has an endpoint_id equal to `ep-1` - * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoint, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://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 an object representing {@link protos.google.cloud.servicedirectory.v1.ResolveServiceResponse|ResolveServiceResponse}. - * Please see the {@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/lookup_service.resolve_service.js - * region_tag:servicedirectory_v1_generated_LookupService_ResolveService_async - */ + /** + * Returns a {@link protos.google.cloud.servicedirectory.v1.Service|service} and its + * associated endpoints. + * Resolving a service is not considered an active developer method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service to resolve. + * @param {number} [request.maxEndpoints] + * Optional. The maximum number of endpoints to return. Defaults to 25. + * Maximum is 100. If a value less than one is specified, the Default is used. + * If a value greater than the Maximum is specified, the Maximum is used. + * @param {string} [request.endpointFilter] + * Optional. The filter applied to the endpoints of the resolved service. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, or `annotations.` for + * map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns endpoints that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * + * `name=projects/my-project/locations/us-central1/namespaces/my-namespace/services/my-service/endpoints/ep-1` + * returns the endpoint that has an endpoint_id equal to `ep-1` + * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoint, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://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 an object representing {@link protos.google.cloud.servicedirectory.v1.ResolveServiceResponse|ResolveServiceResponse}. + * Please see the {@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/lookup_service.resolve_service.js + * region_tag:servicedirectory_v1_generated_LookupService_ResolveService_async + */ resolveService( - request?: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ] + >; resolveService( - request: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resolveService( - request: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resolveService( - request?: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IResolveServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resolveService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resolveService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resolveService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1.IResolveServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('resolveService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resolveService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resolveService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -512,12 +603,11 @@ export class LookupServiceClient { | 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. @@ -550,7 +640,7 @@ export class LookupServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -569,7 +659,13 @@ export class LookupServiceClient { * @param {string} endpoint * @returns {string} Resource name string. */ - endpointPath(project:string,location:string,namespace:string,service:string,endpoint:string) { + endpointPath( + project: string, + location: string, + namespace: string, + service: string, + endpoint: string, + ) { return this.pathTemplates.endpointPathTemplate.render({ project: project, location: location, @@ -609,7 +705,8 @@ export class LookupServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromEndpointName(endpointName: string) { - return this.pathTemplates.endpointPathTemplate.match(endpointName).namespace; + return this.pathTemplates.endpointPathTemplate.match(endpointName) + .namespace; } /** @@ -642,7 +739,7 @@ export class LookupServiceClient { * @param {string} namespace * @returns {string} Resource name string. */ - namespacePath(project:string,location:string,namespace:string) { + namespacePath(project: string, location: string, namespace: string) { return this.pathTemplates.namespacePathTemplate.render({ project: project, location: location, @@ -658,7 +755,8 @@ export class LookupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).project; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .project; } /** @@ -669,7 +767,8 @@ export class LookupServiceClient { * @returns {string} A string representing the location. */ matchLocationFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).location; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .location; } /** @@ -680,7 +779,8 @@ export class LookupServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).namespace; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .namespace; } /** @@ -692,7 +792,12 @@ export class LookupServiceClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,namespace:string,service:string) { + servicePath( + project: string, + location: string, + namespace: string, + service: string, + ) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -753,13 +858,15 @@ export class LookupServiceClient { */ close(): Promise { if (this.lookupServiceStub && !this._terminated) { - return this.lookupServiceStub.then(stub => { + return this.lookupServiceStub.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-servicedirectory/src/v1/registration_service_client.ts b/packages/google-cloud-servicedirectory/src/v1/registration_service_client.ts index 1dc6658962ca..7b3dedfc7c74 100644 --- a/packages/google-cloud-servicedirectory/src/v1/registration_service_client.ts +++ b/packages/google-cloud-servicedirectory/src/v1/registration_service_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 @@ -58,7 +67,7 @@ export class RegistrationServiceClient { 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('service-directory'); @@ -71,10 +80,10 @@ export class RegistrationServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - registrationServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + registrationServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of RegistrationServiceClient. @@ -115,21 +124,42 @@ export class RegistrationServiceClient { * const client = new RegistrationServiceClient({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 RegistrationServiceClient; - 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 = 'servicedirectory.' + 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 +184,7 @@ export class RegistrationServiceClient { 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; @@ -168,15 +198,11 @@ export class RegistrationServiceClient { } 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 { @@ -198,16 +224,16 @@ export class RegistrationServiceClient { // Create useful helper objects for these. this.pathTemplates = { endpointPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), namespacePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}' + 'projects/{project}/locations/{location}/namespaces/{namespace}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', ), }; @@ -215,18 +241,30 @@ export class RegistrationServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listNamespaces: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'namespaces'), - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listEndpoints: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'endpoints') + listNamespaces: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'namespaces', + ), + listServices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'services', + ), + listEndpoints: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'endpoints', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.servicedirectory.v1.RegistrationService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.servicedirectory.v1.RegistrationService', + 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 @@ -257,37 +295,60 @@ export class RegistrationServiceClient { // Put together the "service stub" for // google.cloud.servicedirectory.v1.RegistrationService. this.registrationServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.servicedirectory.v1.RegistrationService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.servicedirectory.v1.RegistrationService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.servicedirectory.v1.RegistrationService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.servicedirectory.v1 + .RegistrationService, + 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 registrationServiceStubMethods = - ['createNamespace', 'listNamespaces', 'getNamespace', 'updateNamespace', 'deleteNamespace', 'createService', 'listServices', 'getService', 'updateService', 'deleteService', 'createEndpoint', 'listEndpoints', 'getEndpoint', 'updateEndpoint', 'deleteEndpoint', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + const registrationServiceStubMethods = [ + 'createNamespace', + 'listNamespaces', + 'getNamespace', + 'updateNamespace', + 'deleteNamespace', + 'createService', + 'listServices', + 'getService', + 'updateService', + 'deleteService', + 'createEndpoint', + 'listEndpoints', + 'getEndpoint', + 'updateEndpoint', + 'deleteEndpoint', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + ]; for (const methodName of registrationServiceStubMethods) { const callPromise = this.registrationServiceStub.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; @@ -302,8 +363,14 @@ export class RegistrationServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -314,8 +381,14 @@ export class RegistrationServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -346,9 +419,7 @@ export class RegistrationServiceClient { * @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; @@ -357,8 +428,9 @@ export class RegistrationServiceClient { * 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; @@ -369,1601 +441,2268 @@ export class RegistrationServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a namespace, and returns the new namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project and location the namespace - * will be created in. - * @param {string} request.namespaceId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1.Namespace} request.namespace - * Required. A namespace with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. - * Please see the {@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/registration_service.create_namespace.js - * region_tag:servicedirectory_v1_generated_RegistrationService_CreateNamespace_async - */ + /** + * Creates a namespace, and returns the new namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project and location the namespace + * will be created in. + * @param {string} request.namespaceId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1.Namespace} request.namespace + * Required. A namespace with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. + * Please see the {@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/registration_service.create_namespace.js + * region_tag:servicedirectory_v1_generated_RegistrationService_CreateNamespace_async + */ createNamespace( - request?: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; createNamespace( - request: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createNamespace( - request: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createNamespace( - request?: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('createNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the namespace to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. - * Please see the {@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/registration_service.get_namespace.js - * region_tag:servicedirectory_v1_generated_RegistrationService_GetNamespace_async - */ + /** + * Gets a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the namespace to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. + * Please see the {@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/registration_service.get_namespace.js + * region_tag:servicedirectory_v1_generated_RegistrationService_GetNamespace_async + */ getNamespace( - request?: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest | undefined, + {} | undefined, + ] + >; getNamespace( - request: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNamespace( - request: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNamespace( - request?: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.IGetNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1.Namespace} request.namespace - * Required. The updated namespace. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. - * Please see the {@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/registration_service.update_namespace.js - * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateNamespace_async - */ + /** + * Updates a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1.Namespace} request.namespace + * Required. The updated namespace. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1.Namespace|Namespace}. + * Please see the {@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/registration_service.update_namespace.js + * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateNamespace_async + */ updateNamespace( - request?: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; updateNamespace( - request: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateNamespace( - request: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateNamespace( - request?: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'namespace.name': request.namespace!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'namespace.name': request.namespace!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.INamespace, + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.INamespace, - protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 namespace. This also deletes all services and endpoints in - * the namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the namespace to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_namespace.js - * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteNamespace_async - */ + /** + * Deletes a namespace. This also deletes all services and endpoints in + * the namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the namespace to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_namespace.js + * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteNamespace_async + */ deleteNamespace( - request?: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; deleteNamespace( - request: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteNamespace( - request: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteNamespace( - request?: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 service, and returns the new service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the namespace this service will belong to. - * @param {string} request.serviceId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1.Service} request.service - * Required. A service with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.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/registration_service.create_service.js - * region_tag:servicedirectory_v1_generated_RegistrationService_CreateService_async - */ + /** + * Creates a service, and returns the new service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the namespace this service will belong to. + * @param {string} request.serviceId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1.Service} request.service + * Required. A service with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.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/registration_service.create_service.js + * region_tag:servicedirectory_v1_generated_RegistrationService_CreateService_async + */ createService( - request?: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.v1.ICreateServiceRequest | undefined, + {} | undefined, + ] + >; createService( - request: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createService( - request: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createService( - request?: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.ICreateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.v1.ICreateServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.ICreateServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('createService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IService, + ( + | protos.google.cloud.servicedirectory.v1.ICreateServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service 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.servicedirectory.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/registration_service.get_service.js - * region_tag:servicedirectory_v1_generated_RegistrationService_GetService_async - */ + /** + * Gets a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service 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.servicedirectory.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/registration_service.get_service.js + * region_tag:servicedirectory_v1_generated_RegistrationService_GetService_async + */ getService( - request?: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.v1.IGetServiceRequest | undefined, + {} | undefined, + ] + >; getService( - request: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request?: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IGetServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.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.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IGetServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.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.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.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.servicedirectory.v1.IService, + ( + | protos.google.cloud.servicedirectory.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; }); } -/** - * Updates a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1.Service} request.service - * Required. The updated service. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.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/registration_service.update_service.js - * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateService_async - */ + /** + * Updates a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1.Service} request.service + * Required. The updated service. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.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/registration_service.update_service.js + * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateService_async + */ updateService( - request?: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest | undefined, + {} | undefined, + ] + >; updateService( - request: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateService( - request: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateService( - request?: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService, + protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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}); this._log.info('updateService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IService, + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IService, - protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IService, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 service. This also deletes all endpoints associated with - * the service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_service.js - * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteService_async - */ + /** + * Deletes a service. This also deletes all endpoints associated with + * the service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_service.js + * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteService_async + */ deleteService( - request?: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest | undefined, + {} | undefined, + ] + >; deleteService( - request: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteService( - request: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteService( - request?: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteService request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint, and returns the new endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the service that this endpoint provides. - * @param {string} request.endpointId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1.Endpoint} request.endpoint - * Required. A endpoint with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.create_endpoint.js - * region_tag:servicedirectory_v1_generated_RegistrationService_CreateEndpoint_async - */ + /** + * Creates an endpoint, and returns the new endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the service that this endpoint provides. + * @param {string} request.endpointId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1.Endpoint} request.endpoint + * Required. A endpoint with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.create_endpoint.js + * region_tag:servicedirectory_v1_generated_RegistrationService_CreateEndpoint_async + */ createEndpoint( - request?: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ] + >; createEndpoint( - request: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request?: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('createEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint 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.servicedirectory.v1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.get_endpoint.js - * region_tag:servicedirectory_v1_generated_RegistrationService_GetEndpoint_async - */ + /** + * Gets an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint 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.servicedirectory.v1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.get_endpoint.js + * region_tag:servicedirectory_v1_generated_RegistrationService_GetEndpoint_async + */ getEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + protos.google.cloud.servicedirectory.v1.IGetEndpointRequest | undefined, + {} | undefined, + ] + >; getEndpoint( - request: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IGetEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + protos.google.cloud.servicedirectory.v1.IGetEndpointRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IGetEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.IGetEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 an endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1.Endpoint} request.endpoint - * Required. The updated endpoint. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.update_endpoint.js - * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_async - */ + /** + * Updates an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1.Endpoint} request.endpoint + * Required. The updated endpoint. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.update_endpoint.js + * region_tag:servicedirectory_v1_generated_RegistrationService_UpdateEndpoint_async + */ updateEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ] + >; updateEndpoint( - request: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateEndpoint( - request: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.name': request.endpoint!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'endpoint.name': request.endpoint!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1.IEndpoint, + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1.IEndpoint, - protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_endpoint.js - * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_async - */ + /** + * Deletes an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/registration_service.delete_endpoint.js + * region_tag:servicedirectory_v1_generated_RegistrationService_DeleteEndpoint_async + */ deleteEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ] + >; deleteEndpoint( - request: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request?: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 IAM Policy for a resource (namespace or service only). - * - * @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 {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/registration_service.get_iam_policy.js - * region_tag:servicedirectory_v1_generated_RegistrationService_GetIamPolicy_async - */ + /** + * Gets the IAM Policy for a resource (namespace or service only). + * + * @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 {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/registration_service.get_iam_policy.js + * region_tag:servicedirectory_v1_generated_RegistrationService_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('getIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Sets the IAM Policy for a resource (namespace or service only). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/registration_service.set_iam_policy.js - * region_tag:servicedirectory_v1_generated_RegistrationService_SetIamPolicy_async - */ + /** + * Sets the IAM Policy for a resource (namespace or service only). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/registration_service.set_iam_policy.js + * region_tag:servicedirectory_v1_generated_RegistrationService_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('setIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('setIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('setIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .setIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('setIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Tests IAM permissions for a resource (namespace or service only). - * - * @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 - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@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/registration_service.test_iam_permissions.js - * region_tag:servicedirectory_v1_generated_RegistrationService_TestIamPermissions_async - */ + /** + * Tests IAM permissions for a resource (namespace or service only). + * + * @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 + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@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/registration_service.test_iam_permissions.js + * region_tag:servicedirectory_v1_generated_RegistrationService_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('testIamPermissions request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('testIamPermissions response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, - {}|undefined - ]) => { - this._log.info('testIamPermissions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .testIamPermissions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('testIamPermissions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all namespaces. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `labels.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value - * `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace}. - * 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 `listNamespacesAsync()` - * method described below for async iteration which you can stop as 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 namespaces. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `labels.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value + * `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace}. + * 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 `listNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNamespaces( - request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace[], - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace[], + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1.IListNamespacesResponse, + ] + >; listNamespaces( - request: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.INamespace>): void; + request: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.INamespace + >, + ): void; listNamespaces( - request: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.INamespace>): void; + request: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.INamespace + >, + ): void; listNamespaces( - request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.INamespace>, - callback?: PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.INamespace>): - Promise<[ - protos.google.cloud.servicedirectory.v1.INamespace[], - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.INamespace + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.INamespace + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.INamespace[], + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1.IListNamespacesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicedirectory.v1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.INamespace>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.INamespace + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listNamespaces values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1972,317 +2711,346 @@ export class RegistrationServiceClient { this._log.info('listNamespaces request %j', request); return this.innerApiCalls .listNamespaces(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1.INamespace[], - protos.google.cloud.servicedirectory.v1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1.IListNamespacesResponse - ]) => { - this._log.info('listNamespaces values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1.INamespace[], + protos.google.cloud.servicedirectory.v1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1.IListNamespacesResponse, + ]) => { + this._log.info('listNamespaces values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listNamespaces`, 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 project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `labels.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value - * `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace} 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 `listNamespacesAsync()` - * method described below for async iteration which you can stop as 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 `listNamespaces`, 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 project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `labels.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value + * `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace} 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 `listNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNamespacesStream( - request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + 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['listNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNamespaces stream %j', request); return this.descriptors.page.listNamespaces.createStream( this.innerApiCalls.listNamespaces as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listNamespaces`, 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 project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `labels.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value - * `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace}. 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/registration_service.list_namespaces.js - * region_tag:servicedirectory_v1_generated_RegistrationService_ListNamespaces_async - */ + /** + * Equivalent to `listNamespaces`, 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 project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `labels.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value + * `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Namespace|Namespace}. 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/registration_service.list_namespaces.js + * region_tag:servicedirectory_v1_generated_RegistrationService_ListNamespaces_async + */ listNamespacesAsync( - request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.v1.IListNamespacesRequest, + 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['listNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNamespaces iterate %j', request); return this.descriptors.page.listNamespaces.asyncIterate( this.innerApiCalls['listNamespaces'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all services belonging to a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `annotations.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns services that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns services that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.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 all services belonging to a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `annotations.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns services that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns services that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.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.servicedirectory.v1.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService[], - protos.google.cloud.servicedirectory.v1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1.IListServicesResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1.IListServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService[], + protos.google.cloud.servicedirectory.v1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.v1.IListServicesResponse, + ] + >; listServices( - request: protos.google.cloud.servicedirectory.v1.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IService>): void; + request: protos.google.cloud.servicedirectory.v1.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IService + >, + ): void; listServices( - request: protos.google.cloud.servicedirectory.v1.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IService>): void; + request: protos.google.cloud.servicedirectory.v1.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IService + >, + ): void; listServices( - request?: protos.google.cloud.servicedirectory.v1.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1.IListServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IService>, - callback?: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IService>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IService[], - protos.google.cloud.servicedirectory.v1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1.IListServicesResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IService + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IService + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IService[], + protos.google.cloud.servicedirectory.v1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.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.servicedirectory.v1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2291,324 +3059,353 @@ export class RegistrationServiceClient { this._log.info('listServices request %j', request); return this.innerApiCalls .listServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1.IService[], - protos.google.cloud.servicedirectory.v1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1.IListServicesResponse - ]) => { - this._log.info('listServices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1.IService[], + protos.google.cloud.servicedirectory.v1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.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 resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `annotations.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns services that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns services that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.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 resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `annotations.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns services that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns services that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.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.servicedirectory.v1.IListServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.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 resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `annotations.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns services that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns services that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.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/registration_service.list_services.js - * region_tag:servicedirectory_v1_generated_RegistrationService_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 resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `annotations.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns services that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns services that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.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/registration_service.list_services.js + * region_tag:servicedirectory_v1_generated_RegistrationService_ListServices_async + */ listServicesAsync( - request?: protos.google.cloud.servicedirectory.v1.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.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 all endpoints. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, or `annotations.` for - * map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns endpoints that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint}. - * 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 `listEndpointsAsync()` - * method described below for async iteration which you can stop as 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 endpoints. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, or `annotations.` for + * map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns endpoints that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint}. + * 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 `listEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpoints( - request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint[], - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint[], + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1.IListEndpointsResponse, + ] + >; listEndpoints( - request: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IEndpoint>): void; + request: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IEndpoint + >, + ): void; listEndpoints( - request: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IEndpoint>): void; + request: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IEndpoint + >, + ): void; listEndpoints( - request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IEndpoint>, - callback?: PaginationCallback< - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IEndpoint>): - Promise<[ - protos.google.cloud.servicedirectory.v1.IEndpoint[], - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IEndpoint + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IEndpoint + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1.IEndpoint[], + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1.IListEndpointsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicedirectory.v1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1.IEndpoint>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1.IEndpoint + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEndpoints values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2617,203 +3414,208 @@ export class RegistrationServiceClient { this._log.info('listEndpoints request %j', request); return this.innerApiCalls .listEndpoints(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1.IEndpoint[], - protos.google.cloud.servicedirectory.v1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1.IListEndpointsResponse - ]) => { - this._log.info('listEndpoints values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1.IEndpoint[], + protos.google.cloud.servicedirectory.v1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1.IListEndpointsResponse, + ]) => { + this._log.info('listEndpoints values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, or `annotations.` for - * map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns endpoints that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint} 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 `listEndpointsAsync()` - * method described below for async iteration which you can stop as 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 `listEndpoints`, 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 service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, or `annotations.` for + * map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns endpoints that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint} 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 `listEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointsStream( - request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + 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['listEndpoints']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpoints stream %j', request); return this.descriptors.page.listEndpoints.createStream( this.innerApiCalls.listEndpoints as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, or `annotations.` for - * map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `annotations.owner` returns endpoints that have a annotation with the - * key `owner`, this is the same as `annotations:owner` - * * `annotations.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that - * have `owner` in annotation key but value is not `sd` AND have - * key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint}. 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/registration_service.list_endpoints.js - * region_tag:servicedirectory_v1_generated_RegistrationService_ListEndpoints_async - */ + /** + * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, or `annotations.` for + * map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `annotations.owner` returns endpoints that have a annotation with the + * key `owner`, this is the same as `annotations:owner` + * * `annotations.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `annotations.owner!=sd AND annotations.foo=bar` returns endpoints that + * have `owner` in annotation key but value is not `sd` AND have + * key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1.Endpoint|Endpoint}. 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/registration_service.list_endpoints.js + * region_tag:servicedirectory_v1_generated_RegistrationService_ListEndpoints_async + */ listEndpointsAsync( - request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.v1.IListEndpointsRequest, + 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['listEndpoints']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpoints iterate %j', request); return this.descriptors.page.listEndpoints.asyncIterate( this.innerApiCalls['listEndpoints'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2848,12 +3650,11 @@ export class RegistrationServiceClient { | 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. @@ -2886,7 +3687,7 @@ export class RegistrationServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -2905,7 +3706,13 @@ export class RegistrationServiceClient { * @param {string} endpoint * @returns {string} Resource name string. */ - endpointPath(project:string,location:string,namespace:string,service:string,endpoint:string) { + endpointPath( + project: string, + location: string, + namespace: string, + service: string, + endpoint: string, + ) { return this.pathTemplates.endpointPathTemplate.render({ project: project, location: location, @@ -2945,7 +3752,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromEndpointName(endpointName: string) { - return this.pathTemplates.endpointPathTemplate.match(endpointName).namespace; + return this.pathTemplates.endpointPathTemplate.match(endpointName) + .namespace; } /** @@ -2977,7 +3785,7 @@ export class RegistrationServiceClient { * @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, @@ -3014,7 +3822,7 @@ export class RegistrationServiceClient { * @param {string} namespace * @returns {string} Resource name string. */ - namespacePath(project:string,location:string,namespace:string) { + namespacePath(project: string, location: string, namespace: string) { return this.pathTemplates.namespacePathTemplate.render({ project: project, location: location, @@ -3030,7 +3838,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).project; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .project; } /** @@ -3041,7 +3850,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).location; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .location; } /** @@ -3052,7 +3862,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).namespace; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .namespace; } /** @@ -3064,7 +3875,12 @@ export class RegistrationServiceClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,namespace:string,service:string) { + servicePath( + project: string, + location: string, + namespace: string, + service: string, + ) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -3125,13 +3941,15 @@ export class RegistrationServiceClient { */ close(): Promise { if (this.registrationServiceStub && !this._terminated) { - return this.registrationServiceStub.then(stub => { + return this.registrationServiceStub.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-servicedirectory/src/v1beta1/index.ts b/packages/google-cloud-servicedirectory/src/v1beta1/index.ts index e07a321f9339..0f60415e91f2 100644 --- a/packages/google-cloud-servicedirectory/src/v1beta1/index.ts +++ b/packages/google-cloud-servicedirectory/src/v1beta1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {LookupServiceClient} from './lookup_service_client'; -export {RegistrationServiceClient} from './registration_service_client'; +export { LookupServiceClient } from './lookup_service_client'; +export { RegistrationServiceClient } from './registration_service_client'; diff --git a/packages/google-cloud-servicedirectory/src/v1beta1/lookup_service_client.ts b/packages/google-cloud-servicedirectory/src/v1beta1/lookup_service_client.ts index f30013f859e0..68e7a5d7c4a1 100644 --- a/packages/google-cloud-servicedirectory/src/v1beta1/lookup_service_client.ts +++ b/packages/google-cloud-servicedirectory/src/v1beta1/lookup_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class LookupServiceClient { 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('service-directory'); @@ -57,10 +64,10 @@ export class LookupServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - lookupServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + lookupServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of LookupServiceClient. @@ -101,21 +108,42 @@ export class LookupServiceClient { * const client = new LookupServiceClient({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 LookupServiceClient; - 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 = 'servicedirectory.' + 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 +168,7 @@ export class LookupServiceClient { 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 +182,11 @@ export class LookupServiceClient { } 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,20 +208,23 @@ export class LookupServiceClient { // Create useful helper objects for these. this.pathTemplates = { endpointPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}', ), namespacePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}' + 'projects/{project}/locations/{location}/namespaces/{namespace}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.servicedirectory.v1beta1.LookupService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.servicedirectory.v1beta1.LookupService', + 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 @@ -228,36 +255,41 @@ export class LookupServiceClient { // Put together the "service stub" for // google.cloud.servicedirectory.v1beta1.LookupService. this.lookupServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.servicedirectory.v1beta1.LookupService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.servicedirectory.v1beta1.LookupService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.servicedirectory.v1beta1.LookupService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.servicedirectory.v1beta1 + .LookupService, + 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 lookupServiceStubMethods = - ['resolveService']; + const lookupServiceStubMethods = ['resolveService']; for (const methodName of lookupServiceStubMethods) { const callPromise = this.lookupServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -272,8 +304,14 @@ export class LookupServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -284,8 +322,14 @@ export class LookupServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -316,9 +360,7 @@ export class LookupServiceClient { * @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; @@ -327,8 +369,9 @@ export class LookupServiceClient { * 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; @@ -339,145 +382,194 @@ export class LookupServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns a {@link protos.google.cloud.servicedirectory.v1beta1.Service|service} and its - * associated endpoints. - * Resolving a service is not considered an active developer method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service to resolve. - * @param {number} [request.maxEndpoints] - * Optional. The maximum number of endpoints to return. Defaults to 25. - * Maximum is 100. If a value less than one is specified, the Default is used. - * If a value greater than the Maximum is specified, the Maximum is used. - * @param {string} [request.endpointFilter] - * Optional. The filter applied to the endpoints of the resolved service. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, or `metadata.` for - * map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns endpoints that have a annotation with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * - * `name=projects/my-project/locations/us-central1/namespaces/my-namespace/services/my-service/endpoints/ep-1` - * returns the endpoint that has an endpoint_id equal to `ep-1` - * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have - * `owner` in annotation key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoint, it returns no results - * - * For more information about filtering, see - * [API Filtering](https://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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse|ResolveServiceResponse}. - * Please see the {@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/lookup_service.resolve_service.js - * region_tag:servicedirectory_v1beta1_generated_LookupService_ResolveService_async - */ + /** + * Returns a {@link protos.google.cloud.servicedirectory.v1beta1.Service|service} and its + * associated endpoints. + * Resolving a service is not considered an active developer method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service to resolve. + * @param {number} [request.maxEndpoints] + * Optional. The maximum number of endpoints to return. Defaults to 25. + * Maximum is 100. If a value less than one is specified, the Default is used. + * If a value greater than the Maximum is specified, the Maximum is used. + * @param {string} [request.endpointFilter] + * Optional. The filter applied to the endpoints of the resolved service. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, or `metadata.` for + * map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns endpoints that have a annotation with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * + * `name=projects/my-project/locations/us-central1/namespaces/my-namespace/services/my-service/endpoints/ep-1` + * returns the endpoint that has an endpoint_id equal to `ep-1` + * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have + * `owner` in annotation key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoint, it returns no results + * + * For more information about filtering, see + * [API Filtering](https://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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse|ResolveServiceResponse}. + * Please see the {@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/lookup_service.resolve_service.js + * region_tag:servicedirectory_v1beta1_generated_LookupService_ResolveService_async + */ resolveService( - request?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ] + >; resolveService( - request: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resolveService( - request: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resolveService( - request?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resolveService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resolveService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resolveService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, - protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('resolveService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resolveService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse, + ( + | protos.google.cloud.servicedirectory.v1beta1.IResolveServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resolveService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -512,12 +604,11 @@ export class LookupServiceClient { | 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. @@ -550,7 +641,7 @@ export class LookupServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -569,7 +660,13 @@ export class LookupServiceClient { * @param {string} endpoint * @returns {string} Resource name string. */ - endpointPath(project:string,location:string,namespace:string,service:string,endpoint:string) { + endpointPath( + project: string, + location: string, + namespace: string, + service: string, + endpoint: string, + ) { return this.pathTemplates.endpointPathTemplate.render({ project: project, location: location, @@ -609,7 +706,8 @@ export class LookupServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromEndpointName(endpointName: string) { - return this.pathTemplates.endpointPathTemplate.match(endpointName).namespace; + return this.pathTemplates.endpointPathTemplate.match(endpointName) + .namespace; } /** @@ -642,7 +740,7 @@ export class LookupServiceClient { * @param {string} namespace * @returns {string} Resource name string. */ - namespacePath(project:string,location:string,namespace:string) { + namespacePath(project: string, location: string, namespace: string) { return this.pathTemplates.namespacePathTemplate.render({ project: project, location: location, @@ -658,7 +756,8 @@ export class LookupServiceClient { * @returns {string} A string representing the project. */ matchProjectFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).project; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .project; } /** @@ -669,7 +768,8 @@ export class LookupServiceClient { * @returns {string} A string representing the location. */ matchLocationFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).location; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .location; } /** @@ -680,7 +780,8 @@ export class LookupServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).namespace; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .namespace; } /** @@ -692,7 +793,12 @@ export class LookupServiceClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,namespace:string,service:string) { + servicePath( + project: string, + location: string, + namespace: string, + service: string, + ) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -753,13 +859,15 @@ export class LookupServiceClient { */ close(): Promise { if (this.lookupServiceStub && !this._terminated) { - return this.lookupServiceStub.then(stub => { + return this.lookupServiceStub.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-servicedirectory/src/v1beta1/registration_service_client.ts b/packages/google-cloud-servicedirectory/src/v1beta1/registration_service_client.ts index 115b54e3c28d..9490f1f9532c 100644 --- a/packages/google-cloud-servicedirectory/src/v1beta1/registration_service_client.ts +++ b/packages/google-cloud-servicedirectory/src/v1beta1/registration_service_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 @@ -58,7 +67,7 @@ export class RegistrationServiceClient { 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('service-directory'); @@ -71,10 +80,10 @@ export class RegistrationServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - registrationServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + registrationServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of RegistrationServiceClient. @@ -115,21 +124,42 @@ export class RegistrationServiceClient { * const client = new RegistrationServiceClient({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 RegistrationServiceClient; - 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 = 'servicedirectory.' + 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 +184,7 @@ export class RegistrationServiceClient { 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; @@ -168,15 +198,11 @@ export class RegistrationServiceClient { } 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 { @@ -198,16 +224,16 @@ export class RegistrationServiceClient { // Create useful helper objects for these. this.pathTemplates = { endpointPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}/endpoints/{endpoint}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), namespacePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}' + 'projects/{project}/locations/{location}/namespaces/{namespace}', ), servicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}' + 'projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}', ), }; @@ -215,18 +241,30 @@ export class RegistrationServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listNamespaces: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'namespaces'), - listServices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'services'), - listEndpoints: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'endpoints') + listNamespaces: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'namespaces', + ), + listServices: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'services', + ), + listEndpoints: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'endpoints', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.servicedirectory.v1beta1.RegistrationService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.servicedirectory.v1beta1.RegistrationService', + 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 @@ -257,37 +295,60 @@ export class RegistrationServiceClient { // Put together the "service stub" for // google.cloud.servicedirectory.v1beta1.RegistrationService. this.registrationServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.servicedirectory.v1beta1.RegistrationService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.servicedirectory.v1beta1.RegistrationService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.servicedirectory.v1beta1.RegistrationService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.servicedirectory.v1beta1 + .RegistrationService, + 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 registrationServiceStubMethods = - ['createNamespace', 'listNamespaces', 'getNamespace', 'updateNamespace', 'deleteNamespace', 'createService', 'listServices', 'getService', 'updateService', 'deleteService', 'createEndpoint', 'listEndpoints', 'getEndpoint', 'updateEndpoint', 'deleteEndpoint', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + const registrationServiceStubMethods = [ + 'createNamespace', + 'listNamespaces', + 'getNamespace', + 'updateNamespace', + 'deleteNamespace', + 'createService', + 'listServices', + 'getService', + 'updateService', + 'deleteService', + 'createEndpoint', + 'listEndpoints', + 'getEndpoint', + 'updateEndpoint', + 'deleteEndpoint', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + ]; for (const methodName of registrationServiceStubMethods) { const callPromise = this.registrationServiceStub.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; @@ -302,8 +363,14 @@ export class RegistrationServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -314,8 +381,14 @@ export class RegistrationServiceClient { * @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 'servicedirectory.googleapis.com'; } @@ -346,9 +419,7 @@ export class RegistrationServiceClient { * @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; @@ -357,8 +428,9 @@ export class RegistrationServiceClient { * 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; @@ -369,1604 +441,2307 @@ export class RegistrationServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a namespace, and returns the new namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project and location the namespace - * will be created in. - * @param {string} request.namespaceId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1beta1.Namespace} request.namespace - * Required. A namespace with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. - * Please see the {@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/registration_service.create_namespace.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_async - */ + /** + * Creates a namespace, and returns the new namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project and location the namespace + * will be created in. + * @param {string} request.namespaceId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1beta1.Namespace} request.namespace + * Required. A namespace with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. + * Please see the {@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/registration_service.create_namespace.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateNamespace_async + */ createNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; createNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('createNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the namespace to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. - * Please see the {@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/registration_service.get_namespace.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_async - */ + /** + * Gets a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the namespace to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. + * Please see the {@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/registration_service.get_namespace.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetNamespace_async + */ getNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; getNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('getNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1beta1.Namespace} request.namespace - * Required. The updated namespace. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. - * Please see the {@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/registration_service.update_namespace.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_async - */ + /** + * Updates a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1beta1.Namespace} request.namespace + * Required. The updated namespace. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Namespace|Namespace}. + * Please see the {@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/registration_service.update_namespace.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateNamespace_async + */ updateNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; updateNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'namespace.name': request.namespace!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'namespace.name': request.namespace!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.INamespace, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.INamespace, - protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.INamespace, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 namespace. This also deletes all services and endpoints in - * the namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the namespace to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_namespace.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_async - */ + /** + * Deletes a namespace. This also deletes all services and endpoints in + * the namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the namespace to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_namespace.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteNamespace_async + */ deleteNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ] + >; deleteNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteNamespace( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteNamespace( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteNamespace request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteNamespace response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteNamespace(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteNamespace response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteNamespace(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteNamespaceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteNamespace response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 service, and returns the new service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the namespace this service will belong to. - * @param {string} request.serviceId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1beta1.Service} request.service - * Required. A service with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.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/v1beta1/registration_service.create_service.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateService_async - */ + /** + * Creates a service, and returns the new service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the namespace this service will belong to. + * @param {string} request.serviceId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1beta1.Service} request.service + * Required. A service with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.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/v1beta1/registration_service.create_service.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateService_async + */ createService( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | undefined + ), + {} | undefined, + ] + >; createService( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createService( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createService( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('createService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service 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.servicedirectory.v1beta1.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/v1beta1/registration_service.get_service.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetService_async - */ + /** + * Gets a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service 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.servicedirectory.v1beta1.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/v1beta1/registration_service.get_service.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetService_async + */ getService( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest + | undefined + ), + {} | undefined, + ] + >; getService( - request: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getService( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IGetServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.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; }); } -/** - * Updates a service. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1beta1.Service} request.service - * Required. The updated service. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.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/v1beta1/registration_service.update_service.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateService_async - */ + /** + * Updates a service. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1beta1.Service} request.service + * Required. The updated service. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.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/v1beta1/registration_service.update_service.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateService_async + */ updateService( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | undefined + ), + {} | undefined, + ] + >; updateService( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateService( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateService( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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}); this._log.info('updateService request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IService, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IService, - protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IService, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 service. This also deletes all endpoints associated with - * the service. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the service to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_service.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteService_async - */ + /** + * Deletes a service. This also deletes all endpoints associated with + * the service. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the service to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_service.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteService_async + */ deleteService( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | undefined + ), + {} | undefined, + ] + >; deleteService( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteService( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteService( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteService request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteService response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteService(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteService response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteService(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteServiceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteService response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint, and returns the new endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the service that this endpoint provides. - * @param {string} request.endpointId - * Required. The Resource ID must be 1-63 characters long, and comply with - * RFC1035. - * Specifically, the name must be 1-63 characters long and match the regular - * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first - * character must be a lowercase letter, and all following characters must - * be a dash, lowercase letter, or digit, except the last character, which - * cannot be a dash. - * @param {google.cloud.servicedirectory.v1beta1.Endpoint} request.endpoint - * Required. A endpoint with initial fields set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.create_endpoint.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_async - */ + /** + * Creates an endpoint, and returns the new endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the service that this endpoint provides. + * @param {string} request.endpointId + * Required. The Resource ID must be 1-63 characters long, and comply with + * RFC1035. + * Specifically, the name must be 1-63 characters long and match the regular + * expression `[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?` which means the first + * character must be a lowercase letter, and all following characters must + * be a dash, lowercase letter, or digit, except the last character, which + * cannot be a dash. + * @param {google.cloud.servicedirectory.v1beta1.Endpoint} request.endpoint + * Required. A endpoint with initial fields set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.create_endpoint.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_CreateEndpoint_async + */ createEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ] + >; createEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('createEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.ICreateEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint 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.servicedirectory.v1beta1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.get_endpoint.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_async - */ + /** + * Gets an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint 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.servicedirectory.v1beta1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.get_endpoint.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetEndpoint_async + */ getEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | undefined + ), + {} | undefined, + ] + >; getEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IGetEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 an endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.servicedirectory.v1beta1.Endpoint} request.endpoint - * Required. The updated endpoint. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Endpoint|Endpoint}. - * Please see the {@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/registration_service.update_endpoint.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_async - */ + /** + * Updates an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.servicedirectory.v1beta1.Endpoint} request.endpoint + * Required. The updated endpoint. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. List of fields to be updated in this 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 an object representing {@link protos.google.cloud.servicedirectory.v1beta1.Endpoint|Endpoint}. + * Please see the {@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/registration_service.update_endpoint.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_UpdateEndpoint_async + */ updateEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ] + >; updateEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, - callback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, + callback: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.name': request.endpoint!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'endpoint.name': request.endpoint!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint, - protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint, + ( + | protos.google.cloud.servicedirectory.v1beta1.IUpdateEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 endpoint. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the endpoint to delete. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_endpoint.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_async - */ + /** + * Deletes an endpoint. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the endpoint to delete. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1beta1/registration_service.delete_endpoint.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_DeleteEndpoint_async + */ deleteEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ] + >; deleteEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteEndpoint( - request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteEndpoint request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteEndpoint response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteEndpoint(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteEndpoint response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteEndpoint(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.servicedirectory.v1beta1.IDeleteEndpointRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteEndpoint response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 IAM Policy for a resource - * - * @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 {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/registration_service.get_iam_policy.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_async - */ + /** + * Gets the IAM Policy for a resource + * + * @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 {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/registration_service.get_iam_policy.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('getIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Sets the IAM Policy for a resource - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/registration_service.set_iam_policy.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_async - */ + /** + * Sets the IAM Policy for a resource + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/registration_service.set_iam_policy.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('setIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('setIamPolicy response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, - {}|undefined - ]) => { - this._log.info('setIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .setIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('setIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Tests IAM permissions for a resource (namespace, service or - * service workload only). - * - * @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 - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@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/registration_service.test_iam_permissions.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_async - */ + /** + * Tests IAM permissions for a resource (namespace, service or + * service workload only). + * + * @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 + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@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/registration_service.test_iam_permissions.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('testIamPermissions request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('testIamPermissions response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, - {}|undefined - ]) => { - this._log.info('testIamPermissions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .testIamPermissions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('testIamPermissions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all namespaces. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `labels.` for map field, or - * `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * * `attributes.managed_registration=true` returns namespaces that are - * managed by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace}. - * 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 `listNamespacesAsync()` - * method described below for async iteration which you can stop as 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 namespaces. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `labels.` for map field, or + * `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * * `attributes.managed_registration=true` returns namespaces that are + * managed by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace}. + * 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 `listNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNamespaces( - request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace[], - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace[], + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse, + ] + >; listNamespaces( - request: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.INamespace>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.INamespace + >, + ): void; listNamespaces( - request: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.INamespace>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.INamespace + >, + ): void; listNamespaces( - request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.INamespace>, - callback?: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.INamespace>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.INamespace[], - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.INamespace + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.INamespace + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.INamespace[], + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicedirectory.v1beta1.IListNamespacesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.INamespace>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.INamespace + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listNamespaces values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1975,324 +2750,353 @@ export class RegistrationServiceClient { this._log.info('listNamespaces request %j', request); return this.innerApiCalls .listNamespaces(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1beta1.INamespace[], - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse - ]) => { - this._log.info('listNamespaces values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1beta1.INamespace[], + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListNamespacesResponse, + ]) => { + this._log.info('listNamespaces values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listNamespaces`, 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 project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `labels.` for map field, or - * `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * * `attributes.managed_registration=true` returns namespaces that are - * managed by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace} 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 `listNamespacesAsync()` - * method described below for async iteration which you can stop as 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 `listNamespaces`, 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 project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `labels.` for map field, or + * `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * * `attributes.managed_registration=true` returns namespaces that are + * managed by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace} 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 `listNamespacesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listNamespacesStream( - request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + 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['listNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNamespaces stream %j', request); return this.descriptors.page.listNamespaces.createStream( this.innerApiCalls.listNamespaces as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listNamespaces`, 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 project and location whose namespaces - * you'd like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `labels.` for map field, or - * `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `labels.owner` returns namespaces that have a label with the key - * `owner`, this is the same as `labels:owner` - * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` - * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` - * returns namespaces that have name that is alphabetically later than the - * string, so "namespace-e" is returned but "namespace-a" is not - * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have - * `owner` in label key but value is not `sd` AND have key/value `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that namespace - * doesn't have a field called "doesnotexist". Since the filter does not - * match any namespaces, it returns no results - * * `attributes.managed_registration=true` returns namespaces that are - * managed by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace}. 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/registration_service.list_namespaces.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_async - */ + /** + * Equivalent to `listNamespaces`, 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 project and location whose namespaces + * you'd like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `labels.` for map field, or + * `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `labels.owner` returns namespaces that have a label with the key + * `owner`, this is the same as `labels:owner` + * * `labels.owner=sd` returns namespaces that have key/value `owner=sd` + * * `name>projects/my-project/locations/us-east1/namespaces/namespace-c` + * returns namespaces that have name that is alphabetically later than the + * string, so "namespace-e" is returned but "namespace-a" is not + * * `labels.owner!=sd AND labels.foo=bar` returns namespaces that have + * `owner` in label key but value is not `sd` AND have key/value `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that namespace + * doesn't have a field called "doesnotexist". Since the filter does not + * match any namespaces, it returns no results + * * `attributes.managed_registration=true` returns namespaces that are + * managed by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Namespace|Namespace}. 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/registration_service.list_namespaces.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_ListNamespaces_async + */ listNamespacesAsync( - request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.v1beta1.IListNamespacesRequest, + 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['listNamespaces']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listNamespaces iterate %j', request); return this.descriptors.page.listNamespaces.asyncIterate( this.innerApiCalls['listNamespaces'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists all services belonging to a namespace. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `metadata.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns services that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * * `attributes.managed_registration=true` returns services that are - * managed - * by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.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 all services belonging to a namespace. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `metadata.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns services that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * * `attributes.managed_registration=true` returns services that are + * managed + * by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IListServicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService[], - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService[], + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse, + ] + >; listServices( - request: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IService>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IService + >, + ): void; listServices( - request: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IService>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IService + >, + ): void; listServices( - request?: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IService>, - callback?: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IService>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IService[], - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IService + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IService + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IService[], + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IListServicesRequest, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IService>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IService + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listServices values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2301,332 +3105,361 @@ export class RegistrationServiceClient { this._log.info('listServices request %j', request); return this.innerApiCalls .listServices(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1beta1.IService[], - protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListServicesResponse - ]) => { - this._log.info('listServices values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1beta1.IService[], + protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest | null, + protos.google.cloud.servicedirectory.v1beta1.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 resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `metadata.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns services that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * * `attributes.managed_registration=true` returns services that are - * managed - * by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.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 resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `metadata.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns services that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * * `attributes.managed_registration=true` returns services that are + * managed + * by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.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.servicedirectory.v1beta1.IListServicesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.v1beta1.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 resource name of the namespace whose services you'd - * like to list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name` or `metadata.` for map field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns services that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns services that have key/value - * `protocol=gRPC` - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` - * returns services that have name that is alphabetically later than the - * string, so "service-e" is returned but "service-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that service - * doesn't have a field called "doesnotexist". Since the filter does not - * match any services, it returns no results - * * `attributes.managed_registration=true` returns services that are - * managed - * by a GCP product or service - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows value: `name` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.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/v1beta1/registration_service.list_services.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_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 resource name of the namespace whose services you'd + * like to list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name` or `metadata.` for map field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns services that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns services that have key/value + * `protocol=gRPC` + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/service-c` + * returns services that have name that is alphabetically later than the + * string, so "service-e" is returned but "service-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns services that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that service + * doesn't have a field called "doesnotexist". Since the filter does not + * match any services, it returns no results + * * `attributes.managed_registration=true` returns services that are + * managed + * by a GCP product or service + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows value: `name` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.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/v1beta1/registration_service.list_services.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_ListServices_async + */ listServicesAsync( - request?: protos.google.cloud.servicedirectory.v1beta1.IListServicesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.v1beta1.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 all endpoints. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, `metadata.` for map - * field, or `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns endpoints that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ - * IP` returns endpoints with the corresponding kubernetes_resource_type - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint}. - * 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 `listEndpointsAsync()` - * method described below for async iteration which you can stop as 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 endpoints. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, `metadata.` for map + * field, or `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns endpoints that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ + * IP` returns endpoints with the corresponding kubernetes_resource_type + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint}. + * 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 `listEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpoints( - request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse - ]>; + request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse, + ] + >; listEndpoints( - request: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IEndpoint>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IEndpoint + >, + ): void; listEndpoints( - request: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - callback: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IEndpoint>): void; + request: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + callback: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IEndpoint + >, + ): void; listEndpoints( - request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IEndpoint>, - callback?: PaginationCallback< - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IEndpoint>): - Promise<[ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse - ]>|void { + | protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IEndpoint + >, + callback?: PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IEndpoint + >, + ): Promise< + [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicedirectory.v1beta1.IListEndpointsRequest, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse|null|undefined, - protos.google.cloud.servicedirectory.v1beta1.IEndpoint>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + | protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse + | null + | undefined, + protos.google.cloud.servicedirectory.v1beta1.IEndpoint + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEndpoints values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2635,207 +3468,212 @@ export class RegistrationServiceClient { this._log.info('listEndpoints request %j', request); return this.innerApiCalls .listEndpoints(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest|null, - protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse - ]) => { - this._log.info('listEndpoints values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicedirectory.v1beta1.IEndpoint[], + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest | null, + protos.google.cloud.servicedirectory.v1beta1.IListEndpointsResponse, + ]) => { + this._log.info('listEndpoints values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, `metadata.` for map - * field, or `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns endpoints that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ - * IP` returns endpoints with the corresponding kubernetes_resource_type - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint} 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 `listEndpointsAsync()` - * method described below for async iteration which you can stop as 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 `listEndpoints`, 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 service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, `metadata.` for map + * field, or `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns endpoints that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ + * IP` returns endpoints with the corresponding kubernetes_resource_type + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint} 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 `listEndpointsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEndpointsStream( - request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + 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['listEndpoints']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpoints stream %j', request); return this.descriptors.page.listEndpoints.createStream( this.innerApiCalls.listEndpoints as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to - * list. - * @param {number} [request.pageSize] - * Optional. The maximum number of items to return. The default value is 100. - * @param {string} [request.pageToken] - * Optional. The next_page_token value returned from a previous List request, - * if any. - * @param {string} [request.filter] - * Optional. The filter to list results by. - * - * General `filter` string syntax: - * ` ()` - * - * * `` can be `name`, `address`, `port`, `metadata.` for map - * field, or `attributes.` for attributes field - * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` - * means `HAS`, and is roughly the same as `=` - * * `` must be the same data type as field - * * `` can be `AND`, `OR`, `NOT` - * - * Examples of valid filters: - * - * * `metadata.owner` returns endpoints that have a metadata with the key - * `owner`, this is the same as `metadata:owner` - * * `metadata.protocol=gRPC` returns endpoints that have key/value - * `protocol=gRPC` - * * `address=192.108.1.105` returns endpoints that have this address - * * `port>8080` returns endpoints that have port number larger than 8080 - * * - * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` - * returns endpoints that have name that is alphabetically later than the - * string, so "endpoint-e" is returned but "endpoint-a" is not - * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have - * `owner` in metadata key but value is not `sd` AND have key/value - * `foo=bar` - * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint - * doesn't have a field called "doesnotexist". Since the filter does not - * match any endpoints, it returns no results - * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ - * IP` returns endpoints with the corresponding kubernetes_resource_type - * - * For more information about filtering, see - * [API Filtering](https://aip.dev/160). - * @param {string} [request.orderBy] - * Optional. The order to list results by. - * - * General `order_by` string syntax: ` () (,)` - * - * * `` allows values: `name`, `address`, `port` - * * `` ascending or descending order by ``. If this is - * left blank, `asc` is used - * - * Note that an empty `order_by` string results in default order, which is - * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint}. 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/registration_service.list_endpoints.js - * region_tag:servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_async - */ + /** + * Equivalent to `listEndpoints`, 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 service whose endpoints you'd like to + * list. + * @param {number} [request.pageSize] + * Optional. The maximum number of items to return. The default value is 100. + * @param {string} [request.pageToken] + * Optional. The next_page_token value returned from a previous List request, + * if any. + * @param {string} [request.filter] + * Optional. The filter to list results by. + * + * General `filter` string syntax: + * ` ()` + * + * * `` can be `name`, `address`, `port`, `metadata.` for map + * field, or `attributes.` for attributes field + * * `` can be `<`, `>`, `<=`, `>=`, `!=`, `=`, `:`. Of which `:` + * means `HAS`, and is roughly the same as `=` + * * `` must be the same data type as field + * * `` can be `AND`, `OR`, `NOT` + * + * Examples of valid filters: + * + * * `metadata.owner` returns endpoints that have a metadata with the key + * `owner`, this is the same as `metadata:owner` + * * `metadata.protocol=gRPC` returns endpoints that have key/value + * `protocol=gRPC` + * * `address=192.108.1.105` returns endpoints that have this address + * * `port>8080` returns endpoints that have port number larger than 8080 + * * + * `name>projects/my-project/locations/us-east1/namespaces/my-namespace/services/my-service/endpoints/endpoint-c` + * returns endpoints that have name that is alphabetically later than the + * string, so "endpoint-e" is returned but "endpoint-a" is not + * * `metadata.owner!=sd AND metadata.foo=bar` returns endpoints that have + * `owner` in metadata key but value is not `sd` AND have key/value + * `foo=bar` + * * `doesnotexist.foo=bar` returns an empty list. Note that endpoint + * doesn't have a field called "doesnotexist". Since the filter does not + * match any endpoints, it returns no results + * * `attributes.kubernetes_resource_type=KUBERNETES_RESOURCE_TYPE_CLUSTER_ + * IP` returns endpoints with the corresponding kubernetes_resource_type + * + * For more information about filtering, see + * [API Filtering](https://aip.dev/160). + * @param {string} [request.orderBy] + * Optional. The order to list results by. + * + * General `order_by` string syntax: ` () (,)` + * + * * `` allows values: `name`, `address`, `port` + * * `` ascending or descending order by ``. If this is + * left blank, `asc` is used + * + * Note that an empty `order_by` string results in default order, which is + * order by `name` in ascending 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.servicedirectory.v1beta1.Endpoint|Endpoint}. 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/registration_service.list_endpoints.js + * region_tag:servicedirectory_v1beta1_generated_RegistrationService_ListEndpoints_async + */ listEndpointsAsync( - request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicedirectory.v1beta1.IListEndpointsRequest, + 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['listEndpoints']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEndpoints iterate %j', request); return this.descriptors.page.listEndpoints.asyncIterate( this.innerApiCalls['listEndpoints'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2870,12 +3708,11 @@ export class RegistrationServiceClient { | 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. @@ -2908,7 +3745,7 @@ export class RegistrationServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -2927,7 +3764,13 @@ export class RegistrationServiceClient { * @param {string} endpoint * @returns {string} Resource name string. */ - endpointPath(project:string,location:string,namespace:string,service:string,endpoint:string) { + endpointPath( + project: string, + location: string, + namespace: string, + service: string, + endpoint: string, + ) { return this.pathTemplates.endpointPathTemplate.render({ project: project, location: location, @@ -2967,7 +3810,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromEndpointName(endpointName: string) { - return this.pathTemplates.endpointPathTemplate.match(endpointName).namespace; + return this.pathTemplates.endpointPathTemplate.match(endpointName) + .namespace; } /** @@ -2999,7 +3843,7 @@ export class RegistrationServiceClient { * @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, @@ -3036,7 +3880,7 @@ export class RegistrationServiceClient { * @param {string} namespace * @returns {string} Resource name string. */ - namespacePath(project:string,location:string,namespace:string) { + namespacePath(project: string, location: string, namespace: string) { return this.pathTemplates.namespacePathTemplate.render({ project: project, location: location, @@ -3052,7 +3896,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the project. */ matchProjectFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).project; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .project; } /** @@ -3063,7 +3908,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the location. */ matchLocationFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).location; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .location; } /** @@ -3074,7 +3920,8 @@ export class RegistrationServiceClient { * @returns {string} A string representing the namespace. */ matchNamespaceFromNamespaceName(namespaceName: string) { - return this.pathTemplates.namespacePathTemplate.match(namespaceName).namespace; + return this.pathTemplates.namespacePathTemplate.match(namespaceName) + .namespace; } /** @@ -3086,7 +3933,12 @@ export class RegistrationServiceClient { * @param {string} service * @returns {string} Resource name string. */ - servicePath(project:string,location:string,namespace:string,service:string) { + servicePath( + project: string, + location: string, + namespace: string, + service: string, + ) { return this.pathTemplates.servicePathTemplate.render({ project: project, location: location, @@ -3147,13 +3999,15 @@ export class RegistrationServiceClient { */ close(): Promise { if (this.registrationServiceStub && !this._terminated) { - return this.registrationServiceStub.then(stub => { + return this.registrationServiceStub.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-servicedirectory/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-servicedirectory/system-test/fixtures/sample/src/index.ts index 6f22f95ace4b..46b28d1725c2 100644 --- a/packages/google-cloud-servicedirectory/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-servicedirectory/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 {LookupServiceClient, RegistrationServiceClient} from '@google-cloud/service-directory'; +import { + LookupServiceClient, + RegistrationServiceClient, +} from '@google-cloud/service-directory'; // check that the client class type name can be used function doStuffWithLookupServiceClient(client: LookupServiceClient) { client.close(); } -function doStuffWithRegistrationServiceClient(client: RegistrationServiceClient) { +function doStuffWithRegistrationServiceClient( + client: RegistrationServiceClient, +) { client.close(); } diff --git a/packages/google-cloud-servicedirectory/system-test/install.ts b/packages/google-cloud-servicedirectory/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-servicedirectory/system-test/install.ts +++ b/packages/google-cloud-servicedirectory/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-servicedirectory/test/gapic_lookup_service_v1.ts b/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1.ts index f20fd5a3a407..1eae82256cea 100644 --- a/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1.ts +++ b/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1.ts @@ -19,655 +19,824 @@ 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 lookupserviceModule from '../src'; -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 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.LookupServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new lookupserviceModule.v1.LookupServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new lookupserviceModule.v1.LookupServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new lookupserviceModule.v1.LookupServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new lookupserviceModule.v1.LookupServiceClient(); + 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 = lookupserviceModule.v1.LookupServiceClient.servicePath; - assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = lookupserviceModule.v1.LookupServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new lookupserviceModule.v1.LookupServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 = + lookupserviceModule.v1.LookupServiceClient.servicePath; + assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + lookupserviceModule.v1.LookupServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new lookupserviceModule.v1.LookupServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1.LookupServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1.LookupServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1.LookupServiceClient({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 lookupserviceModule.v1.LookupServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = lookupserviceModule.v1.LookupServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 lookupserviceModule.v1.LookupServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'servicedirectory.configured.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 no option', () => { - const client = new lookupserviceModule.v1.LookupServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new lookupserviceModule.v1.LookupServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = lookupserviceModule.v1.LookupServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.lookupServiceStub, undefined); - await client.initialize(); - assert(client.lookupServiceStub); - }); + it('should create a client with no option', () => { + const client = new lookupserviceModule.v1.LookupServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.lookupServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.lookupServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.lookupServiceStub, undefined); + await client.initialize(); + assert(client.lookupServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.lookupServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.lookupServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('resolveService', () => { - it('invokes resolveService without error', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceResponse() - ); - client.innerApiCalls.resolveService = stubSimpleCall(expectedResponse); - const [response] = await client.resolveService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService 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 lookupserviceModule.v1.LookupServiceClient({ + 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 resolveService without error using callback', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceResponse() - ); - client.innerApiCalls.resolveService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resolveService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IResolveServiceResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService 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 lookupserviceModule.v1.LookupServiceClient({ + 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('resolveService', () => { + it('invokes resolveService without error', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceResponse(), + ); + client.innerApiCalls.resolveService = stubSimpleCall(expectedResponse); + const [response] = await client.resolveService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resolveService with error', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resolveService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resolveService(request), expectedError); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resolveService without error using callback', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceResponse(), + ); + client.innerApiCalls.resolveService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resolveService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IResolveServiceResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resolveService with closed client', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resolveService(request), expectedError); - }); + it('invokes resolveService with error', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resolveService = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resolveService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ - 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)); - }); + + it('invokes resolveService with closed client', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resolveService(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new lookupserviceModule.v1.LookupServiceClient({ + 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 lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ + 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 lookupserviceModule.v1.LookupServiceClient({ - 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 lookupserviceModule.v1.LookupServiceClient({ + 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 lookupserviceModule.v1.LookupServiceClient({ + 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 lookupserviceModule.v1.LookupServiceClient({ + 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('endpoint', async () => { + const fakePath = '/rendered/path/endpoint'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + service: 'serviceValue', + endpoint: 'endpointValue', + }; + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPath', () => { + const result = client.endpointPath( + 'projectValue', + 'locationValue', + 'namespaceValue', + 'serviceValue', + 'endpointValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointName', () => { + const result = client.matchProjectFromEndpointName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointName', () => { + const result = client.matchLocationFromEndpointName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromEndpointName', () => { + const result = client.matchNamespaceFromEndpointName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromEndpointName', () => { + const result = client.matchServiceFromEndpointName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointFromEndpointName', () => { + const result = client.matchEndpointFromEndpointName(fakePath); + assert.strictEqual(result, 'endpointValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('endpoint', async () => { - const fakePath = "/rendered/path/endpoint"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - endpoint: "endpointValue", - }; - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPath', () => { - const result = client.endpointPath("projectValue", "locationValue", "namespaceValue", "serviceValue", "endpointValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointName', () => { - const result = client.matchProjectFromEndpointName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointName', () => { - const result = client.matchLocationFromEndpointName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromEndpointName', () => { - const result = client.matchNamespaceFromEndpointName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromEndpointName', () => { - const result = client.matchServiceFromEndpointName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointFromEndpointName', () => { - const result = client.matchEndpointFromEndpointName(fakePath); - assert.strictEqual(result, "endpointValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('namespace', async () => { - const fakePath = "/rendered/path/namespace"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - }; - const client = new lookupserviceModule.v1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.namespacePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.namespacePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('namespacePath', () => { - const result = client.namespacePath("projectValue", "locationValue", "namespaceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.namespacePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNamespaceName', () => { - const result = client.matchProjectFromNamespaceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromNamespaceName', () => { - const result = client.matchLocationFromNamespaceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromNamespaceName', () => { - const result = client.matchNamespaceFromNamespaceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('namespace', async () => { + const fakePath = '/rendered/path/namespace'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + }; + const client = new lookupserviceModule.v1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.namespacePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.namespacePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('namespacePath', () => { + const result = client.namespacePath( + 'projectValue', + 'locationValue', + 'namespaceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.namespacePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNamespaceName', () => { + const result = client.matchProjectFromNamespaceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNamespaceName', () => { + const result = client.matchLocationFromNamespaceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromNamespaceName', () => { + const result = client.matchNamespaceFromNamespaceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - }; - const client = new lookupserviceModule.v1.LookupServiceClient({ - 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", "namespaceValue", "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('matchNamespaceFromServiceName', () => { - const result = client.matchNamespaceFromServiceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - 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', + namespace: 'namespaceValue', + service: 'serviceValue', + }; + const client = new lookupserviceModule.v1.LookupServiceClient({ + 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', + 'namespaceValue', + '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('matchNamespaceFromServiceName', () => { + const result = client.matchNamespaceFromServiceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + 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-servicedirectory/test/gapic_lookup_service_v1beta1.ts b/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1beta1.ts index 65411791b5f2..bbc208ba31c8 100644 --- a/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1beta1.ts +++ b/packages/google-cloud-servicedirectory/test/gapic_lookup_service_v1beta1.ts @@ -19,655 +19,824 @@ 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 lookupserviceModule from '../src'; -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 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.LookupServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient(); + 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 = lookupserviceModule.v1beta1.LookupServiceClient.servicePath; - assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = lookupserviceModule.v1beta1.LookupServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 = + lookupserviceModule.v1beta1.LookupServiceClient.servicePath; + assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + lookupserviceModule.v1beta1.LookupServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1beta1.LookupServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1beta1.LookupServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 lookupserviceModule.v1beta1.LookupServiceClient({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 lookupserviceModule.v1beta1.LookupServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = lookupserviceModule.v1beta1.LookupServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 lookupserviceModule.v1beta1.LookupServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'servicedirectory.configured.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 no option', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new lookupserviceModule.v1beta1.LookupServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = lookupserviceModule.v1beta1.LookupServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.lookupServiceStub, undefined); - await client.initialize(); - assert(client.lookupServiceStub); - }); + it('should create a client with no option', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.lookupServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.lookupServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.lookupServiceStub, undefined); + await client.initialize(); + assert(client.lookupServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.lookupServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.lookupServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('resolveService', () => { - it('invokes resolveService without error', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse() - ); - client.innerApiCalls.resolveService = stubSimpleCall(expectedResponse); - const [response] = await client.resolveService(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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 resolveService without error using callback', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse() - ); - client.innerApiCalls.resolveService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resolveService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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('resolveService', () => { + it('invokes resolveService without error', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse(), + ); + client.innerApiCalls.resolveService = stubSimpleCall(expectedResponse); + const [response] = await client.resolveService(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resolveService with error', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resolveService = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resolveService(request), expectedError); - const actualRequest = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resolveService as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resolveService without error using callback', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceResponse(), + ); + client.innerApiCalls.resolveService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resolveService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IResolveServiceResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resolveService with closed client', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resolveService(request), expectedError); - }); + it('invokes resolveService with error', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resolveService = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resolveService(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resolveService as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ - 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)); - }); + + it('invokes resolveService with closed client', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ResolveServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resolveService(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + 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 lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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 lookupserviceModule.v1beta1.LookupServiceClient({ - 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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 lookupserviceModule.v1beta1.LookupServiceClient({ + 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('endpoint', async () => { + const fakePath = '/rendered/path/endpoint'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + service: 'serviceValue', + endpoint: 'endpointValue', + }; + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPath', () => { + const result = client.endpointPath( + 'projectValue', + 'locationValue', + 'namespaceValue', + 'serviceValue', + 'endpointValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointName', () => { + const result = client.matchProjectFromEndpointName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointName', () => { + const result = client.matchLocationFromEndpointName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromEndpointName', () => { + const result = client.matchNamespaceFromEndpointName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromEndpointName', () => { + const result = client.matchServiceFromEndpointName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointFromEndpointName', () => { + const result = client.matchEndpointFromEndpointName(fakePath); + assert.strictEqual(result, 'endpointValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('endpoint', async () => { - const fakePath = "/rendered/path/endpoint"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - endpoint: "endpointValue", - }; - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPath', () => { - const result = client.endpointPath("projectValue", "locationValue", "namespaceValue", "serviceValue", "endpointValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointName', () => { - const result = client.matchProjectFromEndpointName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointName', () => { - const result = client.matchLocationFromEndpointName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromEndpointName', () => { - const result = client.matchNamespaceFromEndpointName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromEndpointName', () => { - const result = client.matchServiceFromEndpointName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointFromEndpointName', () => { - const result = client.matchEndpointFromEndpointName(fakePath); - assert.strictEqual(result, "endpointValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('namespace', async () => { - const fakePath = "/rendered/path/namespace"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - }; - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.namespacePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.namespacePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('namespacePath', () => { - const result = client.namespacePath("projectValue", "locationValue", "namespaceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.namespacePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNamespaceName', () => { - const result = client.matchProjectFromNamespaceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromNamespaceName', () => { - const result = client.matchLocationFromNamespaceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromNamespaceName', () => { - const result = client.matchNamespaceFromNamespaceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('namespace', async () => { + const fakePath = '/rendered/path/namespace'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + }; + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.namespacePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.namespacePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('namespacePath', () => { + const result = client.namespacePath( + 'projectValue', + 'locationValue', + 'namespaceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.namespacePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNamespaceName', () => { + const result = client.matchProjectFromNamespaceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNamespaceName', () => { + const result = client.matchLocationFromNamespaceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromNamespaceName', () => { + const result = client.matchNamespaceFromNamespaceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - }; - const client = new lookupserviceModule.v1beta1.LookupServiceClient({ - 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", "namespaceValue", "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('matchNamespaceFromServiceName', () => { - const result = client.matchNamespaceFromServiceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - 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', + namespace: 'namespaceValue', + service: 'serviceValue', + }; + const client = new lookupserviceModule.v1beta1.LookupServiceClient({ + 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', + 'namespaceValue', + '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('matchNamespaceFromServiceName', () => { + const result = client.matchNamespaceFromServiceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + 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-servicedirectory/test/gapic_registration_service_v1.ts b/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1.ts index 9770643d388d..bb7a5eccaef4 100644 --- a/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1.ts +++ b/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1.ts @@ -19,2979 +19,3958 @@ 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 registrationserviceModule 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.RegistrationServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient(); - 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 = registrationserviceModule.v1.RegistrationServiceClient.servicePath; - assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = registrationserviceModule.v1.RegistrationServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = registrationserviceModule.v1.RegistrationServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.registrationServiceStub, undefined); - await client.initialize(); - assert(client.registrationServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.registrationServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.registrationServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); }); - describe('createNamespace', () => { - it('invokes createNamespace without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.createNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.createNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.createNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNamespace with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has universeDomain', () => { + const client = + new registrationserviceModule.v1.RegistrationServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('invokes createNamespace with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createNamespace(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 = + registrationserviceModule.v1.RegistrationServiceClient.servicePath; + assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + registrationserviceModule.v1.RegistrationServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); }); - describe('getNamespace', () => { - it('invokes getNamespace without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.getNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.getNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + }); - it('invokes getNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.getNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace 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 registrationserviceModule.v1.RegistrationServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getNamespace with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = registrationserviceModule.v1.RegistrationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getNamespace with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getNamespace(request), expectedError); - }); + it('should create a client with no option', () => { + const client = + new registrationserviceModule.v1.RegistrationServiceClient(); + assert(client); }); - describe('updateNamespace', () => { - it('invokes updateNamespace without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.updateNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.updateNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('invokes updateNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Namespace() - ); - client.innerApiCalls.updateNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.registrationServiceStub, undefined); + await client.initialize(); + assert(client.registrationServiceStub); + }); - it('invokes updateNamespace with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.registrationServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateNamespace with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateNamespace(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.registrationServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('deleteNamespace', () => { - it('invokes deleteNamespace without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.deleteNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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 deleteNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNamespace( - 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.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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('createNamespace', () => { + it('invokes createNamespace without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.createNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.createNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteNamespace with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createNamespace without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.createNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteNamespace with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteNamespace(request), expectedError); - }); + it('invokes createNamespace with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Service() - ); - client.innerApiCalls.createService = stubSimpleCall(expectedResponse); - const [response] = await client.createService(request); - 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 createNamespace with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createNamespace(request), expectedError); + }); + }); + + describe('getNamespace', () => { + it('invokes getNamespace without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.getNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.getNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Service() - ); - client.innerApiCalls.createService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 getNamespace without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.getNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubSimpleCall(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 getNamespace with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createService with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createService(request), expectedError); - }); + it('invokes getNamespace with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getNamespace(request), expectedError); + }); + }); + + describe('updateNamespace', () => { + it('invokes updateNamespace without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.updateNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.updateNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.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 updateNamespace without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ); + client.innerApiCalls.updateNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.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 updateNamespace with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.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 updateNamespace with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateNamespace(request), expectedError); + }); + }); + + describe('deleteNamespace', () => { + it('invokes deleteNamespace without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.deleteNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.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); - }); + it('invokes deleteNamespace without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNamespace( + 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.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Service() - ); - client.innerApiCalls.updateService = stubSimpleCall(expectedResponse); - const [response] = await client.updateService(request); - 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 deleteNamespace with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Service() - ); - client.innerApiCalls.updateService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 deleteNamespace with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteNamespace(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ); + client.innerApiCalls.createService = stubSimpleCall(expectedResponse); + const [response] = await client.createService(request); + 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 error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubSimpleCall(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 without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ); + client.innerApiCalls.createService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateService(request), expectedError); - }); + it('invokes createService with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubSimpleCall( + 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('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteService = stubSimpleCall(expectedResponse); - const [response] = await client.deleteService(request); - 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 closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createService(request), expectedError); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.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 deleteService without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - 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.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 getService without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ); + client.innerApiCalls.getService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.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 deleteService with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubSimpleCall(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 getService with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.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 deleteService with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteService(request), expectedError); - }); + it('invokes getService with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.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('updateService', () => { + it('invokes updateService without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ); + client.innerApiCalls.updateService = stubSimpleCall(expectedResponse); + const [response] = await client.updateService(request); + 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('createEndpoint', () => { - it('invokes createEndpoint without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.createEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.createEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint 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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ); + client.innerApiCalls.updateService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 createEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.createEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubSimpleCall( + 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 createEndpoint with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateService with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateService(request), expectedError); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteService = stubSimpleCall(expectedResponse); + const [response] = await client.deleteService(request); + 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 createEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createEndpoint(request), expectedError); - }); + it('invokes deleteService without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + 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.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('getEndpoint', () => { - it('invokes getEndpoint without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.getEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteService with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubSimpleCall( + 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 getEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.getEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteService with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteService(request), expectedError); + }); + }); + + describe('createEndpoint', () => { + it('invokes createEndpoint without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.createEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.createEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEndpoint with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpoint without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.createEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEndpoint(request), expectedError); - }); + it('invokes createEndpoint with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateEndpoint', () => { - it('invokes updateEndpoint without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.updateEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEndpoint with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createEndpoint(request), expectedError); + }); + }); + + describe('getEndpoint', () => { + it('invokes getEndpoint without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.getEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.Endpoint() - ); - client.innerApiCalls.updateEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpoint without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.getEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpoint with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEndpoint with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateEndpoint(request), expectedError); - }); + it('invokes getEndpoint with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEndpoint(request), expectedError); + }); + }); + + describe('updateEndpoint', () => { + it('invokes updateEndpoint without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.updateEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteEndpoint', () => { - it('invokes deleteEndpoint without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.deleteEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpoint without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ); + client.innerApiCalls.updateEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEndpoint( - 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.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpoint with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpoint with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateEndpoint with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateEndpoint(request), expectedError); + }); + }); + + describe('deleteEndpoint', () => { + it('invokes deleteEndpoint without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.deleteEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteEndpoint(request), expectedError); - }); + it('invokes deleteEndpoint without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEndpoint( + 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.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEndpoint with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteEndpoint with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteEndpoint(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); + it('invokes getIamPolicy with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); + it('invokes setIamPolicy with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with closed client', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('listNamespaces', () => { + it('invokes listNamespaces without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + ]; + client.innerApiCalls.listNamespaces = stubSimpleCall(expectedResponse); + const [response] = await client.listNamespaces(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with closed client', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); + it('invokes listNamespaces without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + ]; + client.innerApiCalls.listNamespaces = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNamespaces( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicedirectory.v1.INamespace[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listNamespaces', () => { - it('invokes listNamespaces without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - ]; - client.innerApiCalls.listNamespaces = stubSimpleCall(expectedResponse); - const [response] = await client.listNamespaces(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listNamespaces with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNamespaces = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listNamespaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listNamespaces without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - ]; - client.innerApiCalls.listNamespaces = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNamespaces( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.INamespace[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listNamespacesStream without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + ]; + client.descriptors.page.listNamespaces.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1.Namespace[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1.Namespace) => { + 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.listNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNamespaces, request), + ); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listNamespaces with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listNamespaces = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNamespaces(request), expectedError); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listNamespacesStream with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNamespaces.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1.Namespace[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1.Namespace) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNamespaces, request), + ); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listNamespacesStream without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - ]; - client.descriptors.page.listNamespaces.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1.Namespace) => { - 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.listNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNamespaces, request)); - assert( - (client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listNamespaces without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Namespace(), + ), + ]; + client.descriptors.page.listNamespaces.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.v1.INamespace[] = + []; + const iterable = client.listNamespacesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listNamespacesStream with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNamespaces.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1.Namespace) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNamespaces, request)); - assert( - (client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listNamespaces with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNamespaces.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNamespacesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicedirectory.v1.INamespace[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.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('uses async iteration with listNamespaces without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Namespace()), - ]; - client.descriptors.page.listNamespaces.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1.INamespace[] = []; - const iterable = client.listNamespacesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listServices without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + ]; + client.innerApiCalls.listServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IService[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNamespaces with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNamespaces.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNamespacesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicedirectory.v1.INamespace[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNamespaces.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.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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.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.servicedirectory.v1.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.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.servicedirectory.v1.Service[] = []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.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.servicedirectory.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Service(), + ), + ]; + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.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.servicedirectory.v1.Service[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.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 registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.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.servicedirectory.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('listEndpoints', () => { + it('invokes listEndpoints without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + ]; + client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.listEndpoints(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listEndpoints without error using callback', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + ]; + client.innerApiCalls.listEndpoints = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEndpoints( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1.IEndpoint[] | 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 registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.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.servicedirectory.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.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEndpoints', () => { - it('invokes listEndpoints without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - ]; - client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); - const [response] = await client.listEndpoints(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpoints without error using callback', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - ]; - client.innerApiCalls.listEndpoints = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEndpoints( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1.IEndpoint[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpoints with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEndpoints = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEndpoints(request), expectedError); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEndpoints with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEndpoints = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEndpoints(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEndpointsStream without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - ]; - client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEndpointsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1.Endpoint) => { - 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.listEndpoints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpoints, request)); - assert( - (client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEndpointsStream without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + ]; + client.descriptors.page.listEndpoints.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1.Endpoint[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1.Endpoint) => { + 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.listEndpoints.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpoints, request), + ); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEndpointsStream with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEndpointsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1.Endpoint) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpoints, request)); - assert( - (client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listEndpointsStream with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpoints.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1.Endpoint[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1.Endpoint) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpoints, request), + ); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEndpoints without error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1.Endpoint()), - ]; - client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1.IEndpoint[] = []; - const iterable = client.listEndpointsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEndpoints without error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.Endpoint(), + ), + ]; + client.descriptors.page.listEndpoints.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.v1.IEndpoint[] = []; + const iterable = client.listEndpointsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpoints.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listEndpoints with error', async () => { - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEndpointsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicedirectory.v1.IEndpoint[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listEndpoints with error', async () => { + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpoints.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEndpointsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicedirectory.v1.IEndpoint[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpoints.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpoints.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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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 registrationserviceModule.v1.RegistrationServiceClient({ - 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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 registrationserviceModule.v1.RegistrationServiceClient( + { + 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('endpoint', async () => { + const fakePath = '/rendered/path/endpoint'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + service: 'serviceValue', + endpoint: 'endpointValue', + }; + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.endpointPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPath', () => { + const result = client.endpointPath( + 'projectValue', + 'locationValue', + 'namespaceValue', + 'serviceValue', + 'endpointValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointName', () => { + const result = client.matchProjectFromEndpointName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointName', () => { + const result = client.matchLocationFromEndpointName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromEndpointName', () => { + const result = client.matchNamespaceFromEndpointName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromEndpointName', () => { + const result = client.matchServiceFromEndpointName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointFromEndpointName', () => { + const result = client.matchEndpointFromEndpointName(fakePath); + assert.strictEqual(result, 'endpointValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('endpoint', async () => { - const fakePath = "/rendered/path/endpoint"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - endpoint: "endpointValue", - }; - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPath', () => { - const result = client.endpointPath("projectValue", "locationValue", "namespaceValue", "serviceValue", "endpointValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEndpointName', () => { - const result = client.matchProjectFromEndpointName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEndpointName', () => { - const result = client.matchLocationFromEndpointName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromEndpointName', () => { - const result = client.matchNamespaceFromEndpointName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchServiceFromEndpointName', () => { - const result = client.matchServiceFromEndpointName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEndpointFromEndpointName', () => { - const result = client.matchEndpointFromEndpointName(fakePath); - assert.strictEqual(result, "endpointValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - 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('namespace', async () => { - const fakePath = "/rendered/path/namespace"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - }; - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.namespacePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.namespacePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('namespacePath', () => { - const result = client.namespacePath("projectValue", "locationValue", "namespaceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.namespacePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromNamespaceName', () => { - const result = client.matchProjectFromNamespaceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromNamespaceName', () => { - const result = client.matchLocationFromNamespaceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchNamespaceFromNamespaceName', () => { - const result = client.matchNamespaceFromNamespaceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - }; - const client = new registrationserviceModule.v1.RegistrationServiceClient({ - 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", "namespaceValue", "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)); - }); + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + 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('matchNamespaceFromServiceName', () => { - const result = client.matchNamespaceFromServiceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('namespace', async () => { + const fakePath = '/rendered/path/namespace'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + }; + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + client.pathTemplates.namespacePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.namespacePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('namespacePath', () => { + const result = client.namespacePath( + 'projectValue', + 'locationValue', + 'namespaceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.namespacePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNamespaceName', () => { + const result = client.matchProjectFromNamespaceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNamespaceName', () => { + const result = client.matchLocationFromNamespaceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromNamespaceName', () => { + const result = client.matchNamespaceFromNamespaceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.namespacePathTemplate.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', + namespace: 'namespaceValue', + service: 'serviceValue', + }; + const client = new registrationserviceModule.v1.RegistrationServiceClient( + { + 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', + 'namespaceValue', + '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('matchNamespaceFromServiceName', () => { + const result = client.matchNamespaceFromServiceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + 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-servicedirectory/test/gapic_registration_service_v1beta1.ts b/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1beta1.ts index 247dcea50925..71b30d77fa3f 100644 --- a/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1beta1.ts +++ b/packages/google-cloud-servicedirectory/test/gapic_registration_service_v1beta1.ts @@ -19,2979 +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 registrationserviceModule 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('v1beta1.RegistrationServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient(); - 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 = registrationserviceModule.v1beta1.RegistrationServiceClient.servicePath; - assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = registrationserviceModule.v1beta1.RegistrationServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1beta1.RegistrationServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1beta1.RegistrationServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1beta1.RegistrationServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = registrationserviceModule.v1beta1.RegistrationServiceClient.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 = + registrationserviceModule.v1beta1.RegistrationServiceClient + .servicePath; + assert.strictEqual(servicePath, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + registrationserviceModule.v1beta1.RegistrationServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicedirectory.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + }); - it('should create a client with no option', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicedirectory.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'servicedirectory.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.registrationServiceStub, undefined); - await client.initialize(); - assert(client.registrationServiceStub); - }); + it('has port', () => { + const port = + registrationserviceModule.v1beta1.RegistrationServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.registrationServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.registrationServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.registrationServiceStub, undefined); + await client.initialize(); + assert(client.registrationServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.registrationServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.registrationServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createNamespace', () => { - it('invokes createNamespace without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.createNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.createNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.createNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNamespace with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createNamespace with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createNamespace(request), expectedError); - }); - }); - - describe('getNamespace', () => { - it('invokes getNamespace without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.getNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.getNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.getNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNamespace with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getNamespace with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getNamespace(request), expectedError); - }); - }); - - describe('updateNamespace', () => { - it('invokes updateNamespace without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.updateNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.updateNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Namespace() - ); - client.innerApiCalls.updateNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateNamespace( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.INamespace|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNamespace with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateNamespace with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest() - ); - request.namespace ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', ['namespace', 'name']); - request.namespace.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateNamespace(request), expectedError); - }); - }); - - describe('deleteNamespace', () => { - it('invokes deleteNamespace without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteNamespace = stubSimpleCall(expectedResponse); - const [response] = await client.deleteNamespace(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNamespace without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteNamespace = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteNamespace( - 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.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNamespace with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteNamespace = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteNamespace(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteNamespace as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteNamespace with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteNamespace(request), expectedError); - }); - }); - - describe('createService', () => { - it('invokes createService without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Service() - ); - client.innerApiCalls.createService = stubSimpleCall(expectedResponse); - const [response] = await client.createService(request); - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Service() - ); - client.innerApiCalls.createService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createService = stubSimpleCall(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 closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createService(request), expectedError); - }); - }); - - describe('getService', () => { - it('invokes getService without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Service() - ); - client.innerApiCalls.getService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.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('updateService', () => { - it('invokes updateService without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Service() - ); - client.innerApiCalls.updateService = stubSimpleCall(expectedResponse); - const [response] = await client.updateService(request); - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Service() - ); - client.innerApiCalls.updateService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateService( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IService|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateService = stubSimpleCall(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 closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest() - ); - request.service ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', ['service', 'name']); - request.service.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateService(request), expectedError); - }); - }); - - describe('deleteService', () => { - it('invokes deleteService without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteService = stubSimpleCall(expectedResponse); - const [response] = await client.deleteService(request); - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteService = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteService( - 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.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 error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteService = stubSimpleCall(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 closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteService(request), expectedError); - }); - }); - - describe('createEndpoint', () => { - it('invokes createEndpoint without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.createEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.createEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.createEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEndpoint with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createEndpoint(request), expectedError); - }); - }); - - describe('getEndpoint', () => { - it('invokes getEndpoint without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.getEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.getEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEndpoint with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEndpoint(request), expectedError); - }); - }); - - describe('updateEndpoint', () => { - it('invokes updateEndpoint without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.updateEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.Endpoint() - ); - client.innerApiCalls.updateEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateEndpoint( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEndpoint with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes updateEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest() - ); - request.endpoint ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', ['endpoint', 'name']); - request.endpoint.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateEndpoint(request), expectedError); - }); - }); - - describe('deleteEndpoint', () => { - it('invokes deleteEndpoint without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteEndpoint = stubSimpleCall(expectedResponse); - const [response] = await client.deleteEndpoint(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEndpoint without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteEndpoint = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteEndpoint( - 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.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEndpoint with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteEndpoint = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteEndpoint(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteEndpoint as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteEndpoint with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteEndpoint(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('listNamespaces', () => { - it('invokes listNamespaces without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - ]; - client.innerApiCalls.listNamespaces = stubSimpleCall(expectedResponse); - const [response] = await client.listNamespaces(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNamespaces without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - ]; - client.innerApiCalls.listNamespaces = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listNamespaces( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.INamespace[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNamespaces with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listNamespaces = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listNamespaces(request), expectedError); - const actualRequest = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listNamespaces as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listNamespacesStream without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - ]; - client.descriptors.page.listNamespaces.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1beta1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.Namespace) => { - 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.listNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNamespaces, request)); - assert( - (client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listNamespacesStream with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNamespaces.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listNamespacesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1beta1.Namespace[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.Namespace) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listNamespaces, request)); - assert( - (client.descriptors.page.listNamespaces.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNamespaces without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Namespace()), - ]; - client.descriptors.page.listNamespaces.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1beta1.INamespace[] = []; - const iterable = client.listNamespacesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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('createNamespace', () => { + it('invokes createNamespace without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.createNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.createNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNamespace without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.createNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listNamespaces with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listNamespaces.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listNamespacesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicedirectory.v1beta1.INamespace[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listServices', () => { - it('invokes listServices without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - ]; - client.innerApiCalls.listServices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServices( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - ]; - client.descriptors.page.listServices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listServicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1beta1.Service[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.Service[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListServicesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Service()), - ]; - client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1beta1.IService[] = []; - const iterable = client.listServicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNamespace with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createNamespace with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createNamespace(request), expectedError); + }); + }); + + describe('getNamespace', () => { + it('invokes getNamespace without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.getNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.getNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNamespace without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.getNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.INamespace | 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.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('listEndpoints', () => { - it('invokes listEndpoints without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - ]; - client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); - const [response] = await client.listEndpoints(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpoints without error using callback', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - ]; - client.innerApiCalls.listEndpoints = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEndpoints( - request, - (err?: Error|null, result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpoints with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEndpoints = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEndpoints(request), expectedError); - const actualRequest = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEndpoints as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEndpointsStream without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - ]; - client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEndpointsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1beta1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.Endpoint) => { - 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.listEndpoints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpoints, request)); - assert( - (client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listEndpointsStream with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpoints.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEndpointsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicedirectory.v1beta1.Endpoint[] = []; - stream.on('data', (response: protos.google.cloud.servicedirectory.v1beta1.Endpoint) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEndpoints, request)); - assert( - (client.descriptors.page.listEndpoints.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEndpoints without error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - generateSampleMessage(new protos.google.cloud.servicedirectory.v1beta1.Endpoint()), - ]; - client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicedirectory.v1beta1.IEndpoint[] = []; - const iterable = client.listEndpointsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNamespace with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getNamespace with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getNamespace(request), expectedError); + }); + }); + + describe('updateNamespace', () => { + it('invokes updateNamespace without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.updateNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.updateNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNamespace without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ); + client.innerApiCalls.updateNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateNamespace( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.INamespace | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listEndpoints with error', async () => { - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEndpoints.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEndpointsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicedirectory.v1beta1.IEndpoint[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEndpoints.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNamespace with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedHeaderRequestParams = `namespace.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateNamespace with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest(), + ); + request.namespace ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest', + ['namespace', 'name'], + ); + request.namespace.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateNamespace(request), expectedError); + }); + }); + + describe('deleteNamespace', () => { + it('invokes deleteNamespace without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteNamespace = stubSimpleCall(expectedResponse); + const [response] = await client.deleteNamespace(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteNamespace without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteNamespace = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteNamespace( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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('endpoint', async () => { - const fakePath = "/rendered/path/endpoint"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - endpoint: "endpointValue", - }; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.endpointPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.endpointPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('endpointPath', () => { - const result = client.endpointPath("projectValue", "locationValue", "namespaceValue", "serviceValue", "endpointValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.endpointPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromEndpointName', () => { - const result = client.matchProjectFromEndpointName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteNamespace with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteNamespace = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteNamespace(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteNamespace as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromEndpointName', () => { - const result = client.matchLocationFromEndpointName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteNamespace with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteNamespace(request), expectedError); + }); + }); + + describe('createService', () => { + it('invokes createService without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ); + client.innerApiCalls.createService = stubSimpleCall(expectedResponse); + const [response] = await client.createService(request); + 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('matchNamespaceFromEndpointName', () => { - const result = client.matchNamespaceFromEndpointName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createService without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ); + client.innerApiCalls.createService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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('matchServiceFromEndpointName', () => { - const result = client.matchServiceFromEndpointName(fakePath); - assert.strictEqual(result, "serviceValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createService with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createService = stubSimpleCall( + 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('matchEndpointFromEndpointName', () => { - const result = client.matchEndpointFromEndpointName(fakePath); - assert.strictEqual(result, "endpointValue"); - assert((client.pathTemplates.endpointPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createService with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateServiceRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createService(request), expectedError); + }); + }); + + describe('getService', () => { + it('invokes getService without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.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('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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 getService without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ); + client.innerApiCalls.getService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.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('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getService with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.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('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getService with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.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('updateService', () => { + it('invokes updateService without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ); + client.innerApiCalls.updateService = stubSimpleCall(expectedResponse); + const [response] = await client.updateService(request); + 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('namespace', async () => { - const fakePath = "/rendered/path/namespace"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - }; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.namespacePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.namespacePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('namespacePath', () => { - const result = client.namespacePath("projectValue", "locationValue", "namespaceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.namespacePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes updateService without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ); + client.innerApiCalls.updateService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateService( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IService | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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('matchProjectFromNamespaceName', () => { - const result = client.matchProjectFromNamespaceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateService with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedHeaderRequestParams = `service.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateService = stubSimpleCall( + 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('matchLocationFromNamespaceName', () => { - const result = client.matchLocationFromNamespaceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes updateService with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest(), + ); + request.service ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest', + ['service', 'name'], + ); + request.service.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateService(request), expectedError); + }); + }); + + describe('deleteService', () => { + it('invokes deleteService without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteService = stubSimpleCall(expectedResponse); + const [response] = await client.deleteService(request); + 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('matchNamespaceFromNamespaceName', () => { - const result = client.matchNamespaceFromNamespaceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.namespacePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes deleteService without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteService = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteService( + 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.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('service', async () => { - const fakePath = "/rendered/path/service"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - namespace: "namespaceValue", - service: "serviceValue", - }; - const client = new registrationserviceModule.v1beta1.RegistrationServiceClient({ - 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", "namespaceValue", "serviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.servicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes deleteService with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteService = stubSimpleCall( + 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('matchProjectFromServiceName', () => { - const result = client.matchProjectFromServiceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes deleteService with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteService(request), expectedError); + }); + }); + + describe('createEndpoint', () => { + it('invokes createEndpoint without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.createEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.createEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint 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 createEndpoint without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.createEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchNamespaceFromServiceName', () => { - const result = client.matchNamespaceFromServiceName(fakePath); - assert.strictEqual(result, "namespaceValue"); - assert((client.pathTemplates.servicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createEndpoint with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEndpoint 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 createEndpoint with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.CreateEndpointRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createEndpoint(request), expectedError); + }); + }); + + describe('getEndpoint', () => { + it('invokes getEndpoint without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.getEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.getEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEndpoint without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.getEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEndpoint with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getEndpoint with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.GetEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.GetEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEndpoint(request), expectedError); + }); + }); + + describe('updateEndpoint', () => { + it('invokes updateEndpoint without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.updateEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.updateEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEndpoint without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ); + client.innerApiCalls.updateEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateEndpoint( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicedirectory.v1beta1.IEndpoint | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEndpoint with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedHeaderRequestParams = `endpoint.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes updateEndpoint with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest(), + ); + request.endpoint ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest', + ['endpoint', 'name'], + ); + request.endpoint.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateEndpoint(request), expectedError); + }); + }); + + describe('deleteEndpoint', () => { + it('invokes deleteEndpoint without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteEndpoint = stubSimpleCall(expectedResponse); + const [response] = await client.deleteEndpoint(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEndpoint without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteEndpoint = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteEndpoint( + 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.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEndpoint with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteEndpoint = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteEndpoint(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteEndpoint as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteEndpoint with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteEndpoint(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('listNamespaces', () => { + it('invokes listNamespaces without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + ]; + client.innerApiCalls.listNamespaces = stubSimpleCall(expectedResponse); + const [response] = await client.listNamespaces(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNamespaces without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + ]; + client.innerApiCalls.listNamespaces = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listNamespaces( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicedirectory.v1beta1.INamespace[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNamespaces with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listNamespaces = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listNamespaces(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listNamespaces as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listNamespacesStream without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + ]; + client.descriptors.page.listNamespaces.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1beta1.Namespace[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicedirectory.v1beta1.Namespace, + ) => { + 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.listNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNamespaces, request), + ); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listNamespacesStream with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNamespaces.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listNamespacesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1beta1.Namespace[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicedirectory.v1beta1.Namespace, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listNamespaces, request), + ); + assert( + (client.descriptors.page.listNamespaces.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listNamespaces without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Namespace(), + ), + ]; + client.descriptors.page.listNamespaces.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.v1beta1.INamespace[] = + []; + const iterable = client.listNamespacesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listNamespaces with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listNamespaces.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNamespacesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicedirectory.v1beta1.INamespace[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listNamespaces.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listNamespaces.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listServices', () => { + it('invokes listServices without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + ]; + client.innerApiCalls.listServices = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServices( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + ]; + client.descriptors.page.listServices.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listServicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1beta1.Service[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.Service[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListServicesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Service(), + ), + ]; + client.descriptors.page.listServices.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.v1beta1.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListServicesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.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.servicedirectory.v1beta1.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('listEndpoints', () => { + it('invokes listEndpoints without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + ]; + client.innerApiCalls.listEndpoints = stubSimpleCall(expectedResponse); + const [response] = await client.listEndpoints(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEndpoints without error using callback', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + ]; + client.innerApiCalls.listEndpoints = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEndpoints( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicedirectory.v1beta1.IEndpoint[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEndpoints with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEndpoints = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEndpoints(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEndpoints as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEndpointsStream without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + ]; + client.descriptors.page.listEndpoints.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1beta1.Endpoint[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1beta1.Endpoint) => { + 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.listEndpoints.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpoints, request), + ); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listEndpointsStream with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpoints.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listEndpointsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicedirectory.v1beta1.Endpoint[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.servicedirectory.v1beta1.Endpoint) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEndpoints, request), + ); + assert( + (client.descriptors.page.listEndpoints.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listEndpoints without error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.Endpoint(), + ), + ]; + client.descriptors.page.listEndpoints.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicedirectory.v1beta1.IEndpoint[] = + []; + const iterable = client.listEndpointsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpoints.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpoints.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listEndpoints with error', async () => { + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEndpoints.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listEndpointsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicedirectory.v1beta1.IEndpoint[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listEndpoints.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listEndpoints.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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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 registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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('endpoint', async () => { + const fakePath = '/rendered/path/endpoint'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + service: 'serviceValue', + endpoint: 'endpointValue', + }; + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.endpointPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.endpointPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('endpointPath', () => { + const result = client.endpointPath( + 'projectValue', + 'locationValue', + 'namespaceValue', + 'serviceValue', + 'endpointValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.endpointPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEndpointName', () => { + const result = client.matchProjectFromEndpointName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEndpointName', () => { + const result = client.matchLocationFromEndpointName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromEndpointName', () => { + const result = client.matchNamespaceFromEndpointName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchServiceFromEndpointName', () => { + const result = client.matchServiceFromEndpointName(fakePath); + assert.strictEqual(result, 'serviceValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEndpointFromEndpointName', () => { + const result = client.matchEndpointFromEndpointName(fakePath); + assert.strictEqual(result, 'endpointValue'); + assert( + (client.pathTemplates.endpointPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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('namespace', async () => { + const fakePath = '/rendered/path/namespace'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + }; + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.namespacePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.namespacePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('namespacePath', () => { + const result = client.namespacePath( + 'projectValue', + 'locationValue', + 'namespaceValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.namespacePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromNamespaceName', () => { + const result = client.matchProjectFromNamespaceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromNamespaceName', () => { + const result = client.matchLocationFromNamespaceName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchNamespaceFromNamespaceName', () => { + const result = client.matchNamespaceFromNamespaceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + assert( + (client.pathTemplates.namespacePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('service', async () => { + const fakePath = '/rendered/path/service'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + namespace: 'namespaceValue', + service: 'serviceValue', + }; + const client = + new registrationserviceModule.v1beta1.RegistrationServiceClient({ + 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', + 'namespaceValue', + '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('matchNamespaceFromServiceName', () => { + const result = client.matchNamespaceFromServiceName(fakePath); + assert.strictEqual(result, 'namespaceValue'); + 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-servicedirectory/webpack.config.js b/packages/google-cloud-servicedirectory/webpack.config.js index 19c329bb29c1..a2f5474bdc72 100644 --- a/packages/google-cloud-servicedirectory/webpack.config.js +++ b/packages/google-cloud-servicedirectory/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-servicehealth/.eslintignore b/packages/google-cloud-servicehealth/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-servicehealth/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-servicehealth/.eslintrc.json b/packages/google-cloud-servicehealth/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-servicehealth/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-servicehealth/README.md b/packages/google-cloud-servicehealth/README.md index 10b87e71d9c1..1a1f2ece0e62 100644 --- a/packages/google-cloud-servicehealth/README.md +++ b/packages/google-cloud-servicehealth/README.md @@ -98,7 +98,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-servicehealth/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`) @@ -108,7 +108,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-servicehealth/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-servicehealth/protos/protos.d.ts b/packages/google-cloud-servicehealth/protos/protos.d.ts index f4bf63ed0ec3..58796f67cb81 100644 --- a/packages/google-cloud-servicehealth/protos/protos.d.ts +++ b/packages/google-cloud-servicehealth/protos/protos.d.ts @@ -2880,6 +2880,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -2897,6 +2900,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 @@ -3597,6 +3603,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -3611,6 +3620,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 @@ -3689,6 +3701,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 { @@ -4015,6 +4139,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -4029,6 +4156,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 @@ -4353,6 +4483,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, @@ -4469,6 +4702,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -4499,6 +4733,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -4548,6 +4785,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -4682,6 +4922,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -4723,6 +4966,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 @@ -5570,6 +5816,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -5596,6 +5845,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 @@ -6530,6 +6782,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); @@ -6585,6 +6840,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[]; @@ -6805,6 +7063,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. */ @@ -7043,6 +7416,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -7065,6 +7441,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[]; @@ -7654,6 +8033,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. */ @@ -7683,6 +8068,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 @@ -7805,6 +8196,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. */ @@ -7924,8 +8425,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. */ @@ -7940,8 +8444,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. @@ -8474,6 +8981,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-servicehealth/protos/protos.js b/packages/google-cloud-servicehealth/protos/protos.js index 7c6802576dc5..50c60a6b7036 100644 --- a/packages/google-cloud-servicehealth/protos/protos.js +++ b/packages/google-cloud-servicehealth/protos/protos.js @@ -7537,6 +7537,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -7571,6 +7572,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 @@ -7603,6 +7612,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; }; @@ -7654,6 +7665,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; @@ -7705,6 +7720,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; }; @@ -7747,6 +7767,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; }; @@ -7765,8 +7790,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) { @@ -7774,6 +7801,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; }; @@ -9596,6 +9625,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -9621,6 +9651,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 @@ -9647,6 +9685,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; }; @@ -9687,6 +9727,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; @@ -9727,6 +9771,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; }; @@ -9747,6 +9796,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; }; @@ -9763,10 +9817,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; }; @@ -9796,6 +9854,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; })(); @@ -10672,6 +10982,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -10683,6 +10994,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) @@ -10697,6 +11009,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 @@ -10723,6 +11043,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; }; @@ -10753,7 +11076,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) @@ -10763,6 +11086,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; @@ -10803,6 +11149,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; }; @@ -10823,6 +11177,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; }; @@ -10839,10 +11200,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; }; @@ -11481,29 +11850,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; })(); @@ -11750,6 +12364,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 @@ -11764,6 +12379,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; @@ -11788,6 +12404,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 @@ -11810,6 +12427,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -11860,6 +12478,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 @@ -11981,6 +12607,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; }; @@ -12053,6 +12682,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 = []; @@ -12155,6 +12790,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"; @@ -12209,6 +12851,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -12261,6 +12904,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"); @@ -12324,6 +12974,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -12389,6 +13043,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -12445,6 +13100,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; }; @@ -12493,6 +13153,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 */ /** @@ -12598,6 +13259,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 @@ -12650,6 +13319,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; }; @@ -12742,6 +13413,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -12855,6 +13530,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; }; @@ -12954,6 +13638,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; }; @@ -12983,6 +13687,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; @@ -13028,6 +13733,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; }; @@ -15072,6 +15779,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 */ /** @@ -15132,6 +15840,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 @@ -15169,6 +15885,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; }; @@ -15231,6 +15949,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -15299,6 +16021,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; }; @@ -15348,6 +16079,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; }; @@ -15372,6 +16123,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; @@ -15392,6 +16144,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; }; @@ -17710,6 +18464,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 @@ -17830,6 +18585,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 @@ -17904,6 +18667,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(); @@ -18005,6 +18770,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 = []; @@ -18140,6 +18909,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"; @@ -18328,6 +19102,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"); @@ -18425,6 +19204,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")) @@ -18457,6 +19237,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) @@ -18729,6 +19511,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18770,103 +19553,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; @@ -19461,6 +20730,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 */ @@ -19504,6 +20774,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 @@ -19542,6 +20820,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(); @@ -19593,6 +20873,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 = []; @@ -19645,6 +20929,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"; @@ -19678,6 +20967,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"); @@ -19710,6 +21004,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -19717,6 +21012,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) @@ -21156,6 +22453,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 */ /** @@ -21221,6 +22520,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 @@ -21257,6 +22572,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; }; @@ -21317,6 +22636,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; @@ -21407,6 +22734,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; }; @@ -21546,6 +22893,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; }; @@ -21569,6 +22964,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; @@ -21582,6 +22979,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; }; @@ -21709,6 +23110,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; })(); @@ -21893,6 +23507,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21910,6 +23525,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21958,6 +23574,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -22010,6 +23630,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -22118,7 +23742,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 */ /** @@ -22145,12 +23770,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. @@ -22176,10 +23809,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; }; @@ -22220,8 +23855,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: @@ -22264,6 +23903,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22276,10 +23916,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; }; @@ -22307,6 +23952,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -22348,10 +23997,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; }; @@ -22370,13 +24024,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; }; @@ -23591,6 +25248,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-servicehealth/protos/protos.json b/packages/google-cloud-servicehealth/protos/protos.json index af3ab21037a4..fe85ffac67b2 100644 --- a/packages/google-cloud-servicehealth/protos/protos.json +++ b/packages/google-cloud-servicehealth/protos/protos.json @@ -820,8 +820,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": { @@ -1044,6 +1043,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1184,6 +1187,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 + } + } } } }, @@ -1241,6 +1266,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1302,6 +1332,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1335,12 +1378,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, @@ -1379,6 +1429,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1467,6 +1522,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1692,6 +1751,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1742,7 +1805,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1906,6 +1976,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2041,7 +2112,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2069,6 +2141,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2138,6 +2214,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 + } + } } } }, @@ -2226,6 +2322,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2368,6 +2468,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2378,6 +2479,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2388,6 +2490,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2398,6 +2501,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2408,7 +2512,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" } }, @@ -2418,27 +2523,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, @@ -2483,7 +2599,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2498,6 +2620,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 + } + } + } } } }, @@ -2525,11 +2674,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2542,6 +2706,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2627,6 +2797,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { diff --git a/packages/google-cloud-servicehealth/samples/generated/v1/snippet_metadata_google.cloud.servicehealth.v1.json b/packages/google-cloud-servicehealth/samples/generated/v1/snippet_metadata_google.cloud.servicehealth.v1.json index 4d1962231c25..c6d1f3ae9a18 100644 --- a/packages/google-cloud-servicehealth/samples/generated/v1/snippet_metadata_google.cloud.servicehealth.v1.json +++ b/packages/google-cloud-servicehealth/samples/generated/v1/snippet_metadata_google.cloud.servicehealth.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-servicehealth", - "version": "0.7.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-servicehealth/src/v1/index.ts b/packages/google-cloud-servicehealth/src/v1/index.ts index 3f18e4d6689c..b99181225750 100644 --- a/packages/google-cloud-servicehealth/src/v1/index.ts +++ b/packages/google-cloud-servicehealth/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {ServiceHealthClient} from './service_health_client'; +export { ServiceHealthClient } from './service_health_client'; diff --git a/packages/google-cloud-servicehealth/src/v1/service_health_client.ts b/packages/google-cloud-servicehealth/src/v1/service_health_client.ts index ee5385592323..69dec0ec6704 100644 --- a/packages/google-cloud-servicehealth/src/v1/service_health_client.ts +++ b/packages/google-cloud-servicehealth/src/v1/service_health_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 ServiceHealthClient { 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('servicehealth'); @@ -57,10 +66,10 @@ export class ServiceHealthClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - serviceHealthStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + serviceHealthStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of ServiceHealthClient. @@ -101,21 +110,42 @@ export class ServiceHealthClient { * const client = new ServiceHealthClient({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 ServiceHealthClient; - 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 = 'servicehealth.' + 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 ServiceHealthClient { 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 ServiceHealthClient { } 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,13 +210,13 @@ export class ServiceHealthClient { // Create useful helper objects for these. this.pathTemplates = { eventPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/events/{event}' + 'projects/{project}/locations/{location}/events/{event}', ), organizationEventPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/organizationEvents/{event}' + 'organizations/{organization}/locations/{location}/organizationEvents/{event}', ), organizationImpactPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/locations/{location}/organizationImpacts/{organization_impact}' + 'organizations/{organization}/locations/{location}/organizationImpacts/{organization_impact}', ), }; @@ -198,18 +224,30 @@ export class ServiceHealthClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listEvents: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'events'), - listOrganizationEvents: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizationEvents'), - listOrganizationImpacts: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'organizationImpacts') + listEvents: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'events', + ), + listOrganizationEvents: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'organizationEvents', + ), + listOrganizationImpacts: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'organizationImpacts', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.servicehealth.v1.ServiceHealth', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.servicehealth.v1.ServiceHealth', + 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 @@ -240,37 +278,47 @@ export class ServiceHealthClient { // Put together the "service stub" for // google.cloud.servicehealth.v1.ServiceHealth. this.serviceHealthStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.servicehealth.v1.ServiceHealth') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.servicehealth.v1.ServiceHealth', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.servicehealth.v1.ServiceHealth, - 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 serviceHealthStubMethods = - ['listEvents', 'getEvent', 'listOrganizationEvents', 'getOrganizationEvent', 'listOrganizationImpacts', 'getOrganizationImpact']; + const serviceHealthStubMethods = [ + 'listEvents', + 'getEvent', + 'listOrganizationEvents', + 'getOrganizationEvent', + 'listOrganizationImpacts', + 'getOrganizationImpact', + ]; for (const methodName of serviceHealthStubMethods) { const callPromise = this.serviceHealthStub.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; @@ -285,8 +333,14 @@ export class ServiceHealthClient { * @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 'servicehealth.googleapis.com'; } @@ -297,8 +351,14 @@ export class ServiceHealthClient { * @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 'servicehealth.googleapis.com'; } @@ -329,9 +389,7 @@ export class ServiceHealthClient { * @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; @@ -340,8 +398,9 @@ export class ServiceHealthClient { * 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; @@ -352,427 +411,584 @@ export class ServiceHealthClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves a resource containing information about an event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Unique name of the event in this scope including project - * and location using the form - * `projects/{project_id}/locations/{location}/events/{event_id}`. - * - * `project_id` - Project ID of the project that contains the event.
- * `location` - The location to get the service health events from.
- * `event_id` - Event ID to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.Event|Event}. - * Please see the {@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/service_health.get_event.js - * region_tag:servicehealth_v1_generated_ServiceHealth_GetEvent_async - */ + /** + * Retrieves a resource containing information about an event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Unique name of the event in this scope including project + * and location using the form + * `projects/{project_id}/locations/{location}/events/{event_id}`. + * + * `project_id` - Project ID of the project that contains the event.
+ * `location` - The location to get the service health events from.
+ * `event_id` - Event ID to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.Event|Event}. + * Please see the {@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/service_health.get_event.js + * region_tag:servicehealth_v1_generated_ServiceHealth_GetEvent_async + */ getEvent( - request?: protos.google.cloud.servicehealth.v1.IGetEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicehealth.v1.IGetEventRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | undefined, + {} | undefined, + ] + >; getEvent( - request: protos.google.cloud.servicehealth.v1.IGetEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | null | undefined, + {} | null | undefined + >, + ): void; getEvent( - request: protos.google.cloud.servicehealth.v1.IGetEventRequest, - callback: Callback< - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetEventRequest, + callback: Callback< + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | null | undefined, + {} | null | undefined + >, + ): void; getEvent( - request?: protos.google.cloud.servicehealth.v1.IGetEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicehealth.v1.IGetEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicehealth.v1.IGetEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getEvent request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicehealth.v1.IEvent, + | protos.google.cloud.servicehealth.v1.IGetEventRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getEvent response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getEvent(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicehealth.v1.IEvent, - protos.google.cloud.servicehealth.v1.IGetEventRequest|undefined, - {}|undefined - ]) => { - this._log.info('getEvent response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getEvent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicehealth.v1.IEvent, + protos.google.cloud.servicehealth.v1.IGetEventRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getEvent response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about an event affecting an - * organization . - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Unique name of the event in this scope including organization and - * event ID using the form - * `organizations/{organization_id}/locations/locations/global/organizationEvents/{event_id}`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
- * `event_id` - Organization event ID to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.OrganizationEvent|OrganizationEvent}. - * Please see the {@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/service_health.get_organization_event.js - * region_tag:servicehealth_v1_generated_ServiceHealth_GetOrganizationEvent_async - */ + /** + * Retrieves a resource containing information about an event affecting an + * organization . + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Unique name of the event in this scope including organization and + * event ID using the form + * `organizations/{organization_id}/locations/locations/global/organizationEvents/{event_id}`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
+ * `event_id` - Organization event ID to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.OrganizationEvent|OrganizationEvent}. + * Please see the {@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/service_health.get_organization_event.js + * region_tag:servicehealth_v1_generated_ServiceHealth_GetOrganizationEvent_async + */ getOrganizationEvent( - request?: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | undefined + ), + {} | undefined, + ] + >; getOrganizationEvent( - request: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOrganizationEvent( - request: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, - callback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, + callback: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOrganizationEvent( - request?: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getOrganizationEvent request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getOrganizationEvent response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getOrganizationEvent(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicehealth.v1.IOrganizationEvent, - protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest|undefined, - {}|undefined - ]) => { - this._log.info('getOrganizationEvent response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getOrganizationEvent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationEventRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getOrganizationEvent response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about impact to an asset under - * an organization affected by a service health event. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource using the form - * `organizations/{organization_id}/locations/global/organizationImpacts/{organization_impact_id}`. - * - * `organization_id` - ID (number) of the organization that contains the - * event. To get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
- * `organization_impact_id` - ID of the [OrganizationImpact - * resource](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.OrganizationImpact|OrganizationImpact}. - * Please see the {@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/service_health.get_organization_impact.js - * region_tag:servicehealth_v1_generated_ServiceHealth_GetOrganizationImpact_async - */ + /** + * Retrieves a resource containing information about impact to an asset under + * an organization affected by a service health event. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource using the form + * `organizations/{organization_id}/locations/global/organizationImpacts/{organization_impact_id}`. + * + * `organization_id` - ID (number) of the organization that contains the + * event. To get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
+ * `organization_impact_id` - ID of the [OrganizationImpact + * resource](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.servicehealth.v1.OrganizationImpact|OrganizationImpact}. + * Please see the {@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/service_health.get_organization_impact.js + * region_tag:servicehealth_v1_generated_ServiceHealth_GetOrganizationImpact_async + */ getOrganizationImpact( - request?: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | undefined + ), + {} | undefined, + ] + >; getOrganizationImpact( - request: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOrganizationImpact( - request: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, - callback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, + callback: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getOrganizationImpact( - request?: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getOrganizationImpact request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getOrganizationImpact response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getOrganizationImpact(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.servicehealth.v1.IOrganizationImpact, - protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest|undefined, - {}|undefined - ]) => { - this._log.info('getOrganizationImpact response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getOrganizationImpact(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact, + ( + | protos.google.cloud.servicehealth.v1.IGetOrganizationImpactRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getOrganizationImpact response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 events under a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `projects/{project_id}/locations/{location}/events`. - * - * `project_id` - ID of the project for which to list service health - * events. - * `location` - The location to get the service health events from. - * To retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are 1 to 100, inclusive. (The default value is 10.) If more results - * are available, the service returns a next_page_token that you can use to - * get the next page of results in subsequent list requests. The service may - * return fewer events than the requested page_size. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous `ListEvents` call to retrieve the - * next page of results. When paginating, all other parameters provided to - * `ListEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms:
- * * field=value for `category` and `state`
- * * field <, >, <=, or >= value for `update_time`
- * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, - * `event_impacts.product.product_name:"Eventarc"` - *
- * - * Multiple filter queries are separated by spaces. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time`, `event_impacts.product.product_name` - * @param {google.cloud.servicehealth.v1.EventView} [request.view] - * Optional. Event fields to include in 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.servicehealth.v1.Event|Event}. - * 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 `listEventsAsync()` - * method described below for async iteration which you can stop as 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 events under a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `projects/{project_id}/locations/{location}/events`. + * + * `project_id` - ID of the project for which to list service health + * events. + * `location` - The location to get the service health events from. + * To retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are 1 to 100, inclusive. (The default value is 10.) If more results + * are available, the service returns a next_page_token that you can use to + * get the next page of results in subsequent list requests. The service may + * return fewer events than the requested page_size. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous `ListEvents` call to retrieve the + * next page of results. When paginating, all other parameters provided to + * `ListEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms:
+ * * field=value for `category` and `state`
+ * * field <, >, <=, or >= value for `update_time`
+ * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, + * `event_impacts.product.product_name:"Eventarc"` + *
+ * + * Multiple filter queries are separated by spaces. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time`, `event_impacts.product.product_name` + * @param {google.cloud.servicehealth.v1.EventView} [request.view] + * Optional. Event fields to include in 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.servicehealth.v1.Event|Event}. + * 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 `listEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEvents( - request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IEvent[], - protos.google.cloud.servicehealth.v1.IListEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListEventsResponse - ]>; + request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IEvent[], + protos.google.cloud.servicehealth.v1.IListEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListEventsResponse, + ] + >; listEvents( - request: protos.google.cloud.servicehealth.v1.IListEventsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListEventsRequest, - protos.google.cloud.servicehealth.v1.IListEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IEvent>): void; + request: protos.google.cloud.servicehealth.v1.IListEventsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListEventsRequest, + | protos.google.cloud.servicehealth.v1.IListEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IEvent + >, + ): void; listEvents( - request: protos.google.cloud.servicehealth.v1.IListEventsRequest, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListEventsRequest, - protos.google.cloud.servicehealth.v1.IListEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IEvent>): void; + request: protos.google.cloud.servicehealth.v1.IListEventsRequest, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListEventsRequest, + | protos.google.cloud.servicehealth.v1.IListEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IEvent + >, + ): void; listEvents( - request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.servicehealth.v1.IListEventsRequest, - protos.google.cloud.servicehealth.v1.IListEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IEvent>, - callback?: PaginationCallback< + request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicehealth.v1.IListEventsRequest, - protos.google.cloud.servicehealth.v1.IListEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IEvent>): - Promise<[ - protos.google.cloud.servicehealth.v1.IEvent[], - protos.google.cloud.servicehealth.v1.IListEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListEventsResponse - ]>|void { + | protos.google.cloud.servicehealth.v1.IListEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IEvent + >, + callback?: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListEventsRequest, + | protos.google.cloud.servicehealth.v1.IListEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IEvent + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IEvent[], + protos.google.cloud.servicehealth.v1.IListEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListEventsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicehealth.v1.IListEventsRequest, - protos.google.cloud.servicehealth.v1.IListEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IEvent>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicehealth.v1.IListEventsRequest, + | protos.google.cloud.servicehealth.v1.IListEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IEvent + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listEvents values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -781,293 +997,322 @@ export class ServiceHealthClient { this._log.info('listEvents request %j', request); return this.innerApiCalls .listEvents(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicehealth.v1.IEvent[], - protos.google.cloud.servicehealth.v1.IListEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListEventsResponse - ]) => { - this._log.info('listEvents values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicehealth.v1.IEvent[], + protos.google.cloud.servicehealth.v1.IListEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListEventsResponse, + ]) => { + this._log.info('listEvents values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listEvents`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `projects/{project_id}/locations/{location}/events`. - * - * `project_id` - ID of the project for which to list service health - * events. - * `location` - The location to get the service health events from. - * To retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are 1 to 100, inclusive. (The default value is 10.) If more results - * are available, the service returns a next_page_token that you can use to - * get the next page of results in subsequent list requests. The service may - * return fewer events than the requested page_size. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous `ListEvents` call to retrieve the - * next page of results. When paginating, all other parameters provided to - * `ListEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms:
- * * field=value for `category` and `state`
- * * field <, >, <=, or >= value for `update_time`
- * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, - * `event_impacts.product.product_name:"Eventarc"` - *
- * - * Multiple filter queries are separated by spaces. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time`, `event_impacts.product.product_name` - * @param {google.cloud.servicehealth.v1.EventView} [request.view] - * Optional. Event fields to include in 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.servicehealth.v1.Event|Event} 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 `listEventsAsync()` - * method described below for async iteration which you can stop as 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 `listEvents`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `projects/{project_id}/locations/{location}/events`. + * + * `project_id` - ID of the project for which to list service health + * events. + * `location` - The location to get the service health events from. + * To retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are 1 to 100, inclusive. (The default value is 10.) If more results + * are available, the service returns a next_page_token that you can use to + * get the next page of results in subsequent list requests. The service may + * return fewer events than the requested page_size. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous `ListEvents` call to retrieve the + * next page of results. When paginating, all other parameters provided to + * `ListEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms:
+ * * field=value for `category` and `state`
+ * * field <, >, <=, or >= value for `update_time`
+ * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, + * `event_impacts.product.product_name:"Eventarc"` + *
+ * + * Multiple filter queries are separated by spaces. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time`, `event_impacts.product.product_name` + * @param {google.cloud.servicehealth.v1.EventView} [request.view] + * Optional. Event fields to include in 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.servicehealth.v1.Event|Event} 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 `listEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listEventsStream( - request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, + 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['listEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEvents stream %j', request); return this.descriptors.page.listEvents.createStream( this.innerApiCalls.listEvents as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listEvents`, 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 using the form - * `projects/{project_id}/locations/{location}/events`. - * - * `project_id` - ID of the project for which to list service health - * events. - * `location` - The location to get the service health events from. - * To retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are 1 to 100, inclusive. (The default value is 10.) If more results - * are available, the service returns a next_page_token that you can use to - * get the next page of results in subsequent list requests. The service may - * return fewer events than the requested page_size. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * Provide Page token returned by a previous `ListEvents` call to retrieve the - * next page of results. When paginating, all other parameters provided to - * `ListEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms:
- * * field=value for `category` and `state`
- * * field <, >, <=, or >= value for `update_time`
- * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, - * `event_impacts.product.product_name:"Eventarc"` - *
- * - * Multiple filter queries are separated by spaces. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time`, `event_impacts.product.product_name` - * @param {google.cloud.servicehealth.v1.EventView} [request.view] - * Optional. Event fields to include in 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.servicehealth.v1.Event|Event}. 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/service_health.list_events.js - * region_tag:servicehealth_v1_generated_ServiceHealth_ListEvents_async - */ + /** + * Equivalent to `listEvents`, 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 using the form + * `projects/{project_id}/locations/{location}/events`. + * + * `project_id` - ID of the project for which to list service health + * events. + * `location` - The location to get the service health events from. + * To retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are 1 to 100, inclusive. (The default value is 10.) If more results + * are available, the service returns a next_page_token that you can use to + * get the next page of results in subsequent list requests. The service may + * return fewer events than the requested page_size. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Provide Page token returned by a previous `ListEvents` call to retrieve the + * next page of results. When paginating, all other parameters provided to + * `ListEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms:
+ * * field=value for `category` and `state`
+ * * field <, >, <=, or >= value for `update_time`
+ * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"`, + * `event_impacts.product.product_name:"Eventarc"` + *
+ * + * Multiple filter queries are separated by spaces. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time`, `event_impacts.product.product_name` + * @param {google.cloud.servicehealth.v1.EventView} [request.view] + * Optional. Event fields to include in 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.servicehealth.v1.Event|Event}. 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/service_health.list_events.js + * region_tag:servicehealth_v1_generated_ServiceHealth_ListEvents_async + */ listEventsAsync( - request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicehealth.v1.IListEventsRequest, + 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['listEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listEvents iterate %j', request); return this.descriptors.page.listEvents.asyncIterate( this.innerApiCalls['listEvents'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists organization events under a given organization and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `organizations/{organization_id}/locations/{location}/organizationEvents`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
- * `location` - The location to get the service health events from. To - * retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. (The default value is `10`.) If more - * results are available, the service returns a `next_page_token` that you can - * use to get the next page of results in subsequent list requests. The - * service may return fewer events than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide Page token returned by a previous `ListOrganizationEvents` call to - * retrieve the next page of results. - * - * When paginating, all other parameters provided to - * `ListOrganizationEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms: - * - * * field=value for `category` and `state` - * * field <, >, <=, or >= value for `update_time` - * - * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` - * - * Multiple filter queries are space-separated. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time` - * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] - * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent}. - * 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 `listOrganizationEventsAsync()` - * method described below for async iteration which you can stop as 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 organization events under a given organization and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `organizations/{organization_id}/locations/{location}/organizationEvents`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
+ * `location` - The location to get the service health events from. To + * retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. (The default value is `10`.) If more + * results are available, the service returns a `next_page_token` that you can + * use to get the next page of results in subsequent list requests. The + * service may return fewer events than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide Page token returned by a previous `ListOrganizationEvents` call to + * retrieve the next page of results. + * + * When paginating, all other parameters provided to + * `ListOrganizationEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms: + * + * * field=value for `category` and `state` + * * field <, >, <=, or >= value for `update_time` + * + * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` + * + * Multiple filter queries are space-separated. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time` + * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] + * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent}. + * 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 `listOrganizationEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOrganizationEvents( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationEvent[], - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse - ]>; + request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent[], + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse, + ] + >; listOrganizationEvents( - request: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationEvent>): void; + request: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationEvent + >, + ): void; listOrganizationEvents( - request: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationEvent>): void; + request: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationEvent + >, + ): void; listOrganizationEvents( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationEvent>, - callback?: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationEvent>): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationEvent[], - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse - ]>|void { + | protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationEvent + >, + callback?: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationEvent + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent[], + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicehealth.v1.IListOrganizationEventsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationEvent>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationEvent + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listOrganizationEvents values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1076,302 +1321,331 @@ export class ServiceHealthClient { this._log.info('listOrganizationEvents request %j', request); return this.innerApiCalls .listOrganizationEvents(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicehealth.v1.IOrganizationEvent[], - protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse - ]) => { - this._log.info('listOrganizationEvents values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicehealth.v1.IOrganizationEvent[], + protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationEventsResponse, + ]) => { + this._log.info('listOrganizationEvents values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listOrganizationEvents`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `organizations/{organization_id}/locations/{location}/organizationEvents`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
- * `location` - The location to get the service health events from. To - * retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. (The default value is `10`.) If more - * results are available, the service returns a `next_page_token` that you can - * use to get the next page of results in subsequent list requests. The - * service may return fewer events than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide Page token returned by a previous `ListOrganizationEvents` call to - * retrieve the next page of results. - * - * When paginating, all other parameters provided to - * `ListOrganizationEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms: - * - * * field=value for `category` and `state` - * * field <, >, <=, or >= value for `update_time` - * - * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` - * - * Multiple filter queries are space-separated. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time` - * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] - * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent} 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 `listOrganizationEventsAsync()` - * method described below for async iteration which you can stop as 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 `listOrganizationEvents`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `organizations/{organization_id}/locations/{location}/organizationEvents`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
+ * `location` - The location to get the service health events from. To + * retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. (The default value is `10`.) If more + * results are available, the service returns a `next_page_token` that you can + * use to get the next page of results in subsequent list requests. The + * service may return fewer events than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide Page token returned by a previous `ListOrganizationEvents` call to + * retrieve the next page of results. + * + * When paginating, all other parameters provided to + * `ListOrganizationEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms: + * + * * field=value for `category` and `state` + * * field <, >, <=, or >= value for `update_time` + * + * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` + * + * Multiple filter queries are space-separated. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time` + * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] + * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent} 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 `listOrganizationEventsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOrganizationEventsStream( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + 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['listOrganizationEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOrganizationEvents stream %j', request); return this.descriptors.page.listOrganizationEvents.createStream( this.innerApiCalls.listOrganizationEvents as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listOrganizationEvents`, 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 using the form - * `organizations/{organization_id}/locations/{location}/organizationEvents`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
- * `location` - The location to get the service health events from. To - * retrieve service health events of category = INCIDENT, use `location` = - * `global`. - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. (The default value is `10`.) If more - * results are available, the service returns a `next_page_token` that you can - * use to get the next page of results in subsequent list requests. The - * service may return fewer events than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide Page token returned by a previous `ListOrganizationEvents` call to - * retrieve the next page of results. - * - * When paginating, all other parameters provided to - * `ListOrganizationEvents` must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression takes the following forms: - * - * * field=value for `category` and `state` - * * field <, >, <=, or >= value for `update_time` - * - * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` - * - * Multiple filter queries are space-separated. Example: - * `category=INCIDENT state=ACTIVE`. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * - * Filter is supported for the following fields: `category`, `state`, - * `update_time` - * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] - * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent}. 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/service_health.list_organization_events.js - * region_tag:servicehealth_v1_generated_ServiceHealth_ListOrganizationEvents_async - */ + /** + * Equivalent to `listOrganizationEvents`, 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 using the form + * `organizations/{organization_id}/locations/{location}/organizationEvents`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id).
+ * `location` - The location to get the service health events from. To + * retrieve service health events of category = INCIDENT, use `location` = + * `global`. + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. (The default value is `10`.) If more + * results are available, the service returns a `next_page_token` that you can + * use to get the next page of results in subsequent list requests. The + * service may return fewer events than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide Page token returned by a previous `ListOrganizationEvents` call to + * retrieve the next page of results. + * + * When paginating, all other parameters provided to + * `ListOrganizationEvents` must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression takes the following forms: + * + * * field=value for `category` and `state` + * * field <, >, <=, or >= value for `update_time` + * + * Examples: `category=INCIDENT`, `update_time>="2000-01-01T11:30:00-04:00"` + * + * Multiple filter queries are space-separated. Example: + * `category=INCIDENT state=ACTIVE`. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * + * Filter is supported for the following fields: `category`, `state`, + * `update_time` + * @param {google.cloud.servicehealth.v1.OrganizationEventView} [request.view] + * Optional. OrganizationEvent fields to include in 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.servicehealth.v1.OrganizationEvent|OrganizationEvent}. 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/service_health.list_organization_events.js + * region_tag:servicehealth_v1_generated_ServiceHealth_ListOrganizationEvents_async + */ listOrganizationEventsAsync( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicehealth.v1.IListOrganizationEventsRequest, + 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['listOrganizationEvents']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOrganizationEvents iterate %j', request); return this.descriptors.page.listOrganizationEvents.asyncIterate( this.innerApiCalls['listOrganizationEvents'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists assets impacted by organization events under a given organization and - * location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `organizations/{organization_id}/locations/{location}/organizationImpacts`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. The default value is `10`. - * - * If more results are available, the service returns a - * `next_page_token` that can be used to get the next page of results in - * subsequent list requests. The service may return fewer - * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) - * than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide `page_token` returned by a previous `ListOrganizationImpacts` call - * to retrieve the next page of results. - * - * When paginating, all other parameters provided to `ListOrganizationImpacts` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression is in the form of `field:value` for checking if a - * repeated field contains a value. - * - * Example: - * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` - * - * To get your `{organization_id}`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * - * Multiple filter queries are separated by spaces. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * Filter is supported for the following fields: `events`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.servicehealth.v1.OrganizationImpact|OrganizationImpact}. - * 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 `listOrganizationImpactsAsync()` - * method described below for async iteration which you can stop as 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 assets impacted by organization events under a given organization and + * location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `organizations/{organization_id}/locations/{location}/organizationImpacts`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. The default value is `10`. + * + * If more results are available, the service returns a + * `next_page_token` that can be used to get the next page of results in + * subsequent list requests. The service may return fewer + * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) + * than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide `page_token` returned by a previous `ListOrganizationImpacts` call + * to retrieve the next page of results. + * + * When paginating, all other parameters provided to `ListOrganizationImpacts` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression is in the form of `field:value` for checking if a + * repeated field contains a value. + * + * Example: + * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` + * + * To get your `{organization_id}`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * + * Multiple filter queries are separated by spaces. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * Filter is supported for the following fields: `events`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.servicehealth.v1.OrganizationImpact|OrganizationImpact}. + * 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 `listOrganizationImpactsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOrganizationImpacts( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationImpact[], - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse - ]>; + request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact[], + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse, + ] + >; listOrganizationImpacts( - request: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationImpact>): void; + request: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationImpact + >, + ): void; listOrganizationImpacts( - request: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - callback: PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationImpact>): void; + request: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + callback: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationImpact + >, + ): void; listOrganizationImpacts( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationImpact>, - callback?: PaginationCallback< + request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationImpact>): - Promise<[ - protos.google.cloud.servicehealth.v1.IOrganizationImpact[], - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse - ]>|void { + | protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationImpact + >, + callback?: PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationImpact + >, + ): Promise< + [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact[], + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.servicehealth.v1.IListOrganizationImpactsRequest, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse|null|undefined, - protos.google.cloud.servicehealth.v1.IOrganizationImpact>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + | protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse + | null + | undefined, + protos.google.cloud.servicehealth.v1.IOrganizationImpact + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listOrganizationImpacts values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1380,181 +1654,186 @@ export class ServiceHealthClient { this._log.info('listOrganizationImpacts request %j', request); return this.innerApiCalls .listOrganizationImpacts(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.servicehealth.v1.IOrganizationImpact[], - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest|null, - protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse - ]) => { - this._log.info('listOrganizationImpacts values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.servicehealth.v1.IOrganizationImpact[], + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest | null, + protos.google.cloud.servicehealth.v1.IListOrganizationImpactsResponse, + ]) => { + this._log.info('listOrganizationImpacts values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listOrganizationImpacts`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value using the form - * `organizations/{organization_id}/locations/{location}/organizationImpacts`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. The default value is `10`. - * - * If more results are available, the service returns a - * `next_page_token` that can be used to get the next page of results in - * subsequent list requests. The service may return fewer - * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) - * than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide `page_token` returned by a previous `ListOrganizationImpacts` call - * to retrieve the next page of results. - * - * When paginating, all other parameters provided to `ListOrganizationImpacts` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression is in the form of `field:value` for checking if a - * repeated field contains a value. - * - * Example: - * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` - * - * To get your `{organization_id}`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * - * Multiple filter queries are separated by spaces. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * Filter is supported for the following fields: `events`. - * @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.servicehealth.v1.OrganizationImpact|OrganizationImpact} 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 `listOrganizationImpactsAsync()` - * method described below for async iteration which you can stop as 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 `listOrganizationImpacts`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value using the form + * `organizations/{organization_id}/locations/{location}/organizationImpacts`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. The default value is `10`. + * + * If more results are available, the service returns a + * `next_page_token` that can be used to get the next page of results in + * subsequent list requests. The service may return fewer + * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) + * than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide `page_token` returned by a previous `ListOrganizationImpacts` call + * to retrieve the next page of results. + * + * When paginating, all other parameters provided to `ListOrganizationImpacts` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression is in the form of `field:value` for checking if a + * repeated field contains a value. + * + * Example: + * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` + * + * To get your `{organization_id}`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * + * Multiple filter queries are separated by spaces. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * Filter is supported for the following fields: `events`. + * @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.servicehealth.v1.OrganizationImpact|OrganizationImpact} 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 `listOrganizationImpactsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listOrganizationImpactsStream( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + 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['listOrganizationImpacts']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOrganizationImpacts stream %j', request); return this.descriptors.page.listOrganizationImpacts.createStream( this.innerApiCalls.listOrganizationImpacts as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listOrganizationImpacts`, 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 using the form - * `organizations/{organization_id}/locations/{location}/organizationImpacts`. - * - * `organization_id` - ID (number) of the project that contains the event. To - * get your `organization_id`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * @param {number} [request.pageSize] - * Optional. The maximum number of events that should be returned. Acceptable - * values are `1` to `100`, inclusive. The default value is `10`. - * - * If more results are available, the service returns a - * `next_page_token` that can be used to get the next page of results in - * subsequent list requests. The service may return fewer - * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) - * than the requested `page_size`. - * @param {string} [request.pageToken] - * Optional. A token identifying a page of results the server should return. - * - * Provide `page_token` returned by a previous `ListOrganizationImpacts` call - * to retrieve the next page of results. - * - * When paginating, all other parameters provided to `ListOrganizationImpacts` - * must match the call that provided the page token. - * @param {string} [request.filter] - * Optional. A filter expression that filters resources listed in the - * response. The expression is in the form of `field:value` for checking if a - * repeated field contains a value. - * - * Example: - * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` - * - * To get your `{organization_id}`, see - * [Getting your organization resource - * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). - * - * Multiple filter queries are separated by spaces. - * - * By default, each expression is an AND expression. However, you can include - * AND and OR expressions explicitly. - * Filter is supported for the following fields: `events`. - * @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.servicehealth.v1.OrganizationImpact|OrganizationImpact}. 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/service_health.list_organization_impacts.js - * region_tag:servicehealth_v1_generated_ServiceHealth_ListOrganizationImpacts_async - */ + /** + * Equivalent to `listOrganizationImpacts`, 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 using the form + * `organizations/{organization_id}/locations/{location}/organizationImpacts`. + * + * `organization_id` - ID (number) of the project that contains the event. To + * get your `organization_id`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * @param {number} [request.pageSize] + * Optional. The maximum number of events that should be returned. Acceptable + * values are `1` to `100`, inclusive. The default value is `10`. + * + * If more results are available, the service returns a + * `next_page_token` that can be used to get the next page of results in + * subsequent list requests. The service may return fewer + * [impacts](/service-health/docs/reference/rest/v1beta/organizations.locations.organizationImpacts#OrganizationImpact) + * than the requested `page_size`. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * + * Provide `page_token` returned by a previous `ListOrganizationImpacts` call + * to retrieve the next page of results. + * + * When paginating, all other parameters provided to `ListOrganizationImpacts` + * must match the call that provided the page token. + * @param {string} [request.filter] + * Optional. A filter expression that filters resources listed in the + * response. The expression is in the form of `field:value` for checking if a + * repeated field contains a value. + * + * Example: + * `events:organizations%2F{organization_id}%2Flocations%2Fglobal%2ForganizationEvents%2Fevent-id` + * + * To get your `{organization_id}`, see + * [Getting your organization resource + * ID](https://cloud.google.com/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). + * + * Multiple filter queries are separated by spaces. + * + * By default, each expression is an AND expression. However, you can include + * AND and OR expressions explicitly. + * Filter is supported for the following fields: `events`. + * @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.servicehealth.v1.OrganizationImpact|OrganizationImpact}. 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/service_health.list_organization_impacts.js + * region_tag:servicehealth_v1_generated_ServiceHealth_ListOrganizationImpacts_async + */ listOrganizationImpactsAsync( - request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.servicehealth.v1.IListOrganizationImpactsRequest, + 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['listOrganizationImpacts']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listOrganizationImpacts iterate %j', request); return this.descriptors.page.listOrganizationImpacts.asyncIterate( this.innerApiCalls['listOrganizationImpacts'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1589,12 +1868,11 @@ export class ServiceHealthClient { | 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. @@ -1627,7 +1905,7 @@ export class ServiceHealthClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1644,7 +1922,7 @@ export class ServiceHealthClient { * @param {string} event * @returns {string} Resource name string. */ - eventPath(project:string,location:string,event:string) { + eventPath(project: string, location: string, event: string) { return this.pathTemplates.eventPathTemplate.render({ project: project, location: location, @@ -1693,7 +1971,7 @@ export class ServiceHealthClient { * @param {string} event * @returns {string} Resource name string. */ - organizationEventPath(organization:string,location:string,event:string) { + organizationEventPath(organization: string, location: string, event: string) { return this.pathTemplates.organizationEventPathTemplate.render({ organization: organization, location: location, @@ -1709,7 +1987,9 @@ export class ServiceHealthClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationEventName(organizationEventName: string) { - return this.pathTemplates.organizationEventPathTemplate.match(organizationEventName).organization; + return this.pathTemplates.organizationEventPathTemplate.match( + organizationEventName, + ).organization; } /** @@ -1720,7 +2000,9 @@ export class ServiceHealthClient { * @returns {string} A string representing the location. */ matchLocationFromOrganizationEventName(organizationEventName: string) { - return this.pathTemplates.organizationEventPathTemplate.match(organizationEventName).location; + return this.pathTemplates.organizationEventPathTemplate.match( + organizationEventName, + ).location; } /** @@ -1731,7 +2013,9 @@ export class ServiceHealthClient { * @returns {string} A string representing the event. */ matchEventFromOrganizationEventName(organizationEventName: string) { - return this.pathTemplates.organizationEventPathTemplate.match(organizationEventName).event; + return this.pathTemplates.organizationEventPathTemplate.match( + organizationEventName, + ).event; } /** @@ -1742,7 +2026,11 @@ export class ServiceHealthClient { * @param {string} organization_impact * @returns {string} Resource name string. */ - organizationImpactPath(organization:string,location:string,organizationImpact:string) { + organizationImpactPath( + organization: string, + location: string, + organizationImpact: string, + ) { return this.pathTemplates.organizationImpactPathTemplate.render({ organization: organization, location: location, @@ -1758,7 +2046,9 @@ export class ServiceHealthClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationImpactName(organizationImpactName: string) { - return this.pathTemplates.organizationImpactPathTemplate.match(organizationImpactName).organization; + return this.pathTemplates.organizationImpactPathTemplate.match( + organizationImpactName, + ).organization; } /** @@ -1769,7 +2059,9 @@ export class ServiceHealthClient { * @returns {string} A string representing the location. */ matchLocationFromOrganizationImpactName(organizationImpactName: string) { - return this.pathTemplates.organizationImpactPathTemplate.match(organizationImpactName).location; + return this.pathTemplates.organizationImpactPathTemplate.match( + organizationImpactName, + ).location; } /** @@ -1779,8 +2071,12 @@ export class ServiceHealthClient { * A fully-qualified path representing OrganizationImpact resource. * @returns {string} A string representing the organization_impact. */ - matchOrganizationImpactFromOrganizationImpactName(organizationImpactName: string) { - return this.pathTemplates.organizationImpactPathTemplate.match(organizationImpactName).organization_impact; + matchOrganizationImpactFromOrganizationImpactName( + organizationImpactName: string, + ) { + return this.pathTemplates.organizationImpactPathTemplate.match( + organizationImpactName, + ).organization_impact; } /** @@ -1791,13 +2087,15 @@ export class ServiceHealthClient { */ close(): Promise { if (this.serviceHealthStub && !this._terminated) { - return this.serviceHealthStub.then(stub => { + return this.serviceHealthStub.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-servicehealth/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-servicehealth/system-test/fixtures/sample/src/index.ts index 833cb312cc7d..ceebc67b494f 100644 --- a/packages/google-cloud-servicehealth/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-servicehealth/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 {ServiceHealthClient} from '@google-cloud/servicehealth'; +import { ServiceHealthClient } from '@google-cloud/servicehealth'; // check that the client class type name can be used function doStuffWithServiceHealthClient(client: ServiceHealthClient) { diff --git a/packages/google-cloud-servicehealth/system-test/install.ts b/packages/google-cloud-servicehealth/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-servicehealth/system-test/install.ts +++ b/packages/google-cloud-servicehealth/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-servicehealth/test/gapic_service_health_v1.ts b/packages/google-cloud-servicehealth/test/gapic_service_health_v1.ts index 405534e72651..c02bd9cfc724 100644 --- a/packages/google-cloud-servicehealth/test/gapic_service_health_v1.ts +++ b/packages/google-cloud-servicehealth/test/gapic_service_health_v1.ts @@ -19,1609 +19,2147 @@ 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 servicehealthModule 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.ServiceHealthClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new servicehealthModule.v1.ServiceHealthClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicehealth.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new servicehealthModule.v1.ServiceHealthClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicehealth.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new servicehealthModule.v1.ServiceHealthClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new servicehealthModule.v1.ServiceHealthClient(); + 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 = servicehealthModule.v1.ServiceHealthClient.servicePath; - assert.strictEqual(servicePath, 'servicehealth.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = servicehealthModule.v1.ServiceHealthClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'servicehealth.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new servicehealthModule.v1.ServiceHealthClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicehealth.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 = + servicehealthModule.v1.ServiceHealthClient.servicePath; + assert.strictEqual(servicePath, 'servicehealth.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + servicehealthModule.v1.ServiceHealthClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'servicehealth.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicehealth.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new servicehealthModule.v1.ServiceHealthClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicehealth.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicehealth.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 servicehealthModule.v1.ServiceHealthClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicehealth.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 servicehealthModule.v1.ServiceHealthClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'servicehealth.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 servicehealthModule.v1.ServiceHealthClient({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 servicehealthModule.v1.ServiceHealthClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'servicehealth.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = servicehealthModule.v1.ServiceHealthClient.port; - assert(port); - assert(typeof port === 'number'); + 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 servicehealthModule.v1.ServiceHealthClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'servicehealth.configured.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 no option', () => { - const client = new servicehealthModule.v1.ServiceHealthClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new servicehealthModule.v1.ServiceHealthClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = servicehealthModule.v1.ServiceHealthClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.serviceHealthStub, undefined); - await client.initialize(); - assert(client.serviceHealthStub); - }); + it('should create a client with no option', () => { + const client = new servicehealthModule.v1.ServiceHealthClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.serviceHealthStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.serviceHealthStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.serviceHealthStub, undefined); + await client.initialize(); + assert(client.serviceHealthStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.serviceHealthStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.serviceHealthStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getEvent', () => { - it('invokes getEvent without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.Event() - ); - client.innerApiCalls.getEvent = stubSimpleCall(expectedResponse); - const [response] = await client.getEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvent 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 servicehealthModule.v1.ServiceHealthClient({ + 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 getEvent without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.Event() - ); - client.innerApiCalls.getEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEvent( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvent 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 servicehealthModule.v1.ServiceHealthClient({ + 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('getEvent', () => { + it('invokes getEvent without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.Event(), + ); + client.innerApiCalls.getEvent = stubSimpleCall(expectedResponse); + const [response] = await client.getEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEvent with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.getEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEvent without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.Event(), + ); + client.innerApiCalls.getEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicehealth.v1.IEvent | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getEvent with closed client', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetEventRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getEvent(request), expectedError); - }); + it('invokes getEvent with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getEvent = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getOrganizationEvent', () => { - it('invokes getOrganizationEvent without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.OrganizationEvent() - ); - client.innerApiCalls.getOrganizationEvent = stubSimpleCall(expectedResponse); - const [response] = await client.getOrganizationEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getEvent with closed client', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getEvent(request), expectedError); + }); + }); + + describe('getOrganizationEvent', () => { + it('invokes getOrganizationEvent without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ); + client.innerApiCalls.getOrganizationEvent = + stubSimpleCall(expectedResponse); + const [response] = await client.getOrganizationEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationEvent without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.OrganizationEvent() - ); - client.innerApiCalls.getOrganizationEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOrganizationEvent( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IOrganizationEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOrganizationEvent without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ); + client.innerApiCalls.getOrganizationEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOrganizationEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicehealth.v1.IOrganizationEvent | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationEvent with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationEventRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOrganizationEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOrganizationEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOrganizationEvent with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOrganizationEvent = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getOrganizationEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationEvent with closed client', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationEventRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getOrganizationEvent(request), expectedError); - }); + it('invokes getOrganizationEvent with closed client', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationEventRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getOrganizationEvent(request), expectedError); + }); + }); + + describe('getOrganizationImpact', () => { + it('invokes getOrganizationImpact without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ); + client.innerApiCalls.getOrganizationImpact = + stubSimpleCall(expectedResponse); + const [response] = await client.getOrganizationImpact(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getOrganizationImpact', () => { - it('invokes getOrganizationImpact without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.OrganizationImpact() - ); - client.innerApiCalls.getOrganizationImpact = stubSimpleCall(expectedResponse); - const [response] = await client.getOrganizationImpact(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOrganizationImpact without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ); + client.innerApiCalls.getOrganizationImpact = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getOrganizationImpact( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicehealth.v1.IOrganizationImpact | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationImpact without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.OrganizationImpact() - ); - client.innerApiCalls.getOrganizationImpact = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getOrganizationImpact( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IOrganizationImpact|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOrganizationImpact with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getOrganizationImpact = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getOrganizationImpact(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getOrganizationImpact as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationImpact with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getOrganizationImpact = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getOrganizationImpact(request), expectedError); - const actualRequest = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getOrganizationImpact as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getOrganizationImpact with closed client', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getOrganizationImpact(request), + expectedError, + ); + }); + }); + + describe('listEvents', () => { + it('invokes listEvents without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + ]; + client.innerApiCalls.listEvents = stubSimpleCall(expectedResponse); + const [response] = await client.listEvents(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getOrganizationImpact with closed client', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.GetOrganizationImpactRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.GetOrganizationImpactRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getOrganizationImpact(request), expectedError); - }); + it('invokes listEvents without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + ]; + client.innerApiCalls.listEvents = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEvents( + request, + ( + err?: Error | null, + result?: protos.google.cloud.servicehealth.v1.IEvent[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEvents', () => { - it('invokes listEvents without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - ]; - client.innerApiCalls.listEvents = stubSimpleCall(expectedResponse); - const [response] = await client.listEvents(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEvents with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEvents = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listEvents(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listEvents without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - ]; - client.innerApiCalls.listEvents = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEvents( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IEvent[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listEventsStream without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + ]; + client.descriptors.page.listEvents.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.Event[] = []; + stream.on( + 'data', + (response: protos.google.cloud.servicehealth.v1.Event) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listEvents with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEvents = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.listEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEvents 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.listEvents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEvents, request), + ); + assert( + (client.descriptors.page.listEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listEventsStream without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - ]; - client.descriptors.page.listEvents.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.Event[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.Event) => { - 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.listEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEvents, request)); - assert( - (client.descriptors.page.listEvents.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listEventsStream with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEvents.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.Event[] = []; + stream.on( + 'data', + (response: protos.google.cloud.servicehealth.v1.Event) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listEventsStream with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEvents.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.Event[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.Event) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listEvents, request)); - assert( - (client.descriptors.page.listEvents.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.listEvents.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listEvents, request), + ); + assert( + (client.descriptors.page.listEvents.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listEvents without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), + ]; + client.descriptors.page.listEvents.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicehealth.v1.IEvent[] = []; + const iterable = client.listEventsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listEvents.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listEvents.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listEvents with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listEvents.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listEventsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicehealth.v1.IEvent[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listEvents.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listEvents.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listOrganizationEvents', () => { + it('invokes listOrganizationEvents without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + ]; + client.innerApiCalls.listOrganizationEvents = + stubSimpleCall(expectedResponse); + const [response] = await client.listOrganizationEvents(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOrganizationEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listEvents without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.Event()), - ]; - client.descriptors.page.listEvents.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicehealth.v1.IEvent[] = []; - const iterable = client.listEventsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listOrganizationEvents without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + ]; + client.innerApiCalls.listOrganizationEvents = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOrganizationEvents( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicehealth.v1.IOrganizationEvent[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEvents.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.listOrganizationEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listEvents with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listEvents.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listEventsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicehealth.v1.IEvent[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listEvents.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listOrganizationEvents with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOrganizationEvents = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listOrganizationEvents(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listOrganizationEvents as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationEvents as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listOrganizationEvents', () => { - it('invokes listOrganizationEvents without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - ]; - client.innerApiCalls.listOrganizationEvents = stubSimpleCall(expectedResponse); - const [response] = await client.listOrganizationEvents(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOrganizationEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listOrganizationEventsStream without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + ]; + client.descriptors.page.listOrganizationEvents.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listOrganizationEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.OrganizationEvent[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicehealth.v1.OrganizationEvent, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listOrganizationEvents without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - ]; - client.innerApiCalls.listOrganizationEvents = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOrganizationEvents( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IOrganizationEvent[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOrganizationEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationEvents 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.listOrganizationEvents + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listOrganizationEvents, request), + ); + assert( + ( + client.descriptors.page.listOrganizationEvents + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listOrganizationEvents with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOrganizationEvents = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOrganizationEvents(request), expectedError); - const actualRequest = (client.innerApiCalls.listOrganizationEvents as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationEvents as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listOrganizationEventsStream with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOrganizationEvents.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listOrganizationEventsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.OrganizationEvent[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicehealth.v1.OrganizationEvent, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listOrganizationEventsStream without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - ]; - client.descriptors.page.listOrganizationEvents.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOrganizationEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.OrganizationEvent[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.OrganizationEvent) => { - 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.listOrganizationEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOrganizationEvents, request)); - assert( - (client.descriptors.page.listOrganizationEvents.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.listOrganizationEvents + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listOrganizationEvents, request), + ); + assert( + ( + client.descriptors.page.listOrganizationEvents + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listOrganizationEventsStream with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOrganizationEvents.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOrganizationEventsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.OrganizationEvent[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.OrganizationEvent) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOrganizationEvents.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOrganizationEvents, request)); - assert( - (client.descriptors.page.listOrganizationEvents.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOrganizationEvents without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationEvent(), + ), + ]; + client.descriptors.page.listOrganizationEvents.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicehealth.v1.IOrganizationEvent[] = + []; + const iterable = client.listOrganizationEventsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listOrganizationEvents + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listOrganizationEvents + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listOrganizationEvents without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationEvent()), - ]; - client.descriptors.page.listOrganizationEvents.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicehealth.v1.IOrganizationEvent[] = []; - const iterable = client.listOrganizationEventsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOrganizationEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOrganizationEvents.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOrganizationEvents with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOrganizationEvents.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOrganizationEventsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicehealth.v1.IOrganizationEvent[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listOrganizationEvents + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listOrganizationEvents + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); + }); + + describe('listOrganizationImpacts', () => { + it('invokes listOrganizationImpacts without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + ]; + client.innerApiCalls.listOrganizationImpacts = + stubSimpleCall(expectedResponse); + const [response] = await client.listOrganizationImpacts(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listOrganizationEvents with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationEventsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationEventsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOrganizationEvents.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOrganizationEventsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicehealth.v1.IOrganizationEvent[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOrganizationEvents.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOrganizationEvents.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listOrganizationImpacts without error using callback', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + ]; + client.innerApiCalls.listOrganizationImpacts = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listOrganizationImpacts( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.servicehealth.v1.IOrganizationImpact[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listOrganizationImpacts', () => { - it('invokes listOrganizationImpacts without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - ]; - client.innerApiCalls.listOrganizationImpacts = stubSimpleCall(expectedResponse); - const [response] = await client.listOrganizationImpacts(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOrganizationImpacts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationImpacts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listOrganizationImpacts with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listOrganizationImpacts = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listOrganizationImpacts(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listOrganizationImpacts as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listOrganizationImpacts without error using callback', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - ]; - client.innerApiCalls.listOrganizationImpacts = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listOrganizationImpacts( - request, - (err?: Error|null, result?: protos.google.cloud.servicehealth.v1.IOrganizationImpact[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listOrganizationImpacts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationImpacts as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listOrganizationImpactsStream without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + ]; + client.descriptors.page.listOrganizationImpacts.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listOrganizationImpactsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.OrganizationImpact[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicehealth.v1.OrganizationImpact, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listOrganizationImpacts with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listOrganizationImpacts = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listOrganizationImpacts(request), expectedError); - const actualRequest = (client.innerApiCalls.listOrganizationImpacts as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listOrganizationImpacts 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.listOrganizationImpacts + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listOrganizationImpacts, request), + ); + assert( + ( + client.descriptors.page.listOrganizationImpacts + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('invokes listOrganizationImpactsStream without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - ]; - client.descriptors.page.listOrganizationImpacts.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listOrganizationImpactsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.OrganizationImpact[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.OrganizationImpact) => { - 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.listOrganizationImpacts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOrganizationImpacts, request)); - assert( - (client.descriptors.page.listOrganizationImpacts.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listOrganizationImpactsStream with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOrganizationImpacts.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listOrganizationImpactsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.servicehealth.v1.OrganizationImpact[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.servicehealth.v1.OrganizationImpact, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listOrganizationImpactsStream with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOrganizationImpacts.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listOrganizationImpactsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.servicehealth.v1.OrganizationImpact[] = []; - stream.on('data', (response: protos.google.cloud.servicehealth.v1.OrganizationImpact) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listOrganizationImpacts.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listOrganizationImpacts, request)); - assert( - (client.descriptors.page.listOrganizationImpacts.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.listOrganizationImpacts + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.listOrganizationImpacts, request), + ); + assert( + ( + client.descriptors.page.listOrganizationImpacts + .createStream as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listOrganizationImpacts without error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - generateSampleMessage(new protos.google.cloud.servicehealth.v1.OrganizationImpact()), - ]; - client.descriptors.page.listOrganizationImpacts.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.servicehealth.v1.IOrganizationImpact[] = []; - const iterable = client.listOrganizationImpactsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listOrganizationImpacts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOrganizationImpacts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOrganizationImpacts without error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + generateSampleMessage( + new protos.google.cloud.servicehealth.v1.OrganizationImpact(), + ), + ]; + client.descriptors.page.listOrganizationImpacts.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.servicehealth.v1.IOrganizationImpact[] = + []; + const iterable = client.listOrganizationImpactsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listOrganizationImpacts + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listOrganizationImpacts + .asyncIterate as SinonStub + ) + .getCall(0) + .args[2].otherArgs.headers['x-goog-request-params'].includes( + expectedHeaderRequestParams, + ), + ); + }); - it('uses async iteration with listOrganizationImpacts with error', async () => { - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listOrganizationImpacts.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listOrganizationImpactsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.servicehealth.v1.IOrganizationImpact[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listOrganizationImpacts.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listOrganizationImpacts.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listOrganizationImpacts with error', async () => { + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.servicehealth.v1.ListOrganizationImpactsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listOrganizationImpacts.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listOrganizationImpactsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.servicehealth.v1.IOrganizationImpact[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listOrganizationImpacts + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + ( + client.descriptors.page.listOrganizationImpacts + .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 servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ + 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 servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ + 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 servicehealthModule.v1.ServiceHealthClient({ - 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 servicehealthModule.v1.ServiceHealthClient({ + 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 servicehealthModule.v1.ServiceHealthClient({ + 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 servicehealthModule.v1.ServiceHealthClient({ + 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('event', async () => { + const fakePath = '/rendered/path/event'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + event: 'eventValue', + }; + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.eventPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.eventPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('eventPath', () => { + const result = client.eventPath( + 'projectValue', + 'locationValue', + 'eventValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.eventPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromEventName', () => { + const result = client.matchProjectFromEventName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.eventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromEventName', () => { + const result = client.matchLocationFromEventName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.eventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEventFromEventName', () => { + const result = client.matchEventFromEventName(fakePath); + assert.strictEqual(result, 'eventValue'); + assert( + (client.pathTemplates.eventPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('event', async () => { - const fakePath = "/rendered/path/event"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - event: "eventValue", - }; - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.eventPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.eventPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('eventPath', () => { - const result = client.eventPath("projectValue", "locationValue", "eventValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.eventPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromEventName', () => { - const result = client.matchProjectFromEventName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.eventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromEventName', () => { - const result = client.matchLocationFromEventName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.eventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEventFromEventName', () => { - const result = client.matchEventFromEventName(fakePath); - assert.strictEqual(result, "eventValue"); - assert((client.pathTemplates.eventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('organizationEvent', async () => { - const fakePath = "/rendered/path/organizationEvent"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - event: "eventValue", - }; - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationEventPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationEventPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationEventPath', () => { - const result = client.organizationEventPath("organizationValue", "locationValue", "eventValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationEventPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationEventName', () => { - const result = client.matchOrganizationFromOrganizationEventName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationEventName', () => { - const result = client.matchLocationFromOrganizationEventName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEventFromOrganizationEventName', () => { - const result = client.matchEventFromOrganizationEventName(fakePath); - assert.strictEqual(result, "eventValue"); - assert((client.pathTemplates.organizationEventPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationEvent', async () => { + const fakePath = '/rendered/path/organizationEvent'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + event: 'eventValue', + }; + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationEventPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationEventPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationEventPath', () => { + const result = client.organizationEventPath( + 'organizationValue', + 'locationValue', + 'eventValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationEventPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationEventName', () => { + const result = + client.matchOrganizationFromOrganizationEventName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationEventPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationEventName', () => { + const result = client.matchLocationFromOrganizationEventName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.organizationEventPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEventFromOrganizationEventName', () => { + const result = client.matchEventFromOrganizationEventName(fakePath); + assert.strictEqual(result, 'eventValue'); + assert( + ( + client.pathTemplates.organizationEventPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationImpact', async () => { - const fakePath = "/rendered/path/organizationImpact"; - const expectedParameters = { - organization: "organizationValue", - location: "locationValue", - organization_impact: "organizationImpactValue", - }; - const client = new servicehealthModule.v1.ServiceHealthClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationImpactPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationImpactPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationImpactPath', () => { - const result = client.organizationImpactPath("organizationValue", "locationValue", "organizationImpactValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationImpactPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationImpactName', () => { - const result = client.matchOrganizationFromOrganizationImpactName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationImpactPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromOrganizationImpactName', () => { - const result = client.matchLocationFromOrganizationImpactName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.organizationImpactPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchOrganizationImpactFromOrganizationImpactName', () => { - const result = client.matchOrganizationImpactFromOrganizationImpactName(fakePath); - assert.strictEqual(result, "organizationImpactValue"); - assert((client.pathTemplates.organizationImpactPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationImpact', async () => { + const fakePath = '/rendered/path/organizationImpact'; + const expectedParameters = { + organization: 'organizationValue', + location: 'locationValue', + organization_impact: 'organizationImpactValue', + }; + const client = new servicehealthModule.v1.ServiceHealthClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationImpactPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationImpactPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationImpactPath', () => { + const result = client.organizationImpactPath( + 'organizationValue', + 'locationValue', + 'organizationImpactValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationImpactPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationImpactName', () => { + const result = + client.matchOrganizationFromOrganizationImpactName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationImpactPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromOrganizationImpactName', () => { + const result = client.matchLocationFromOrganizationImpactName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + ( + client.pathTemplates.organizationImpactPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchOrganizationImpactFromOrganizationImpactName', () => { + const result = + client.matchOrganizationImpactFromOrganizationImpactName(fakePath); + assert.strictEqual(result, 'organizationImpactValue'); + assert( + ( + client.pathTemplates.organizationImpactPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-servicehealth/webpack.config.js b/packages/google-cloud-servicehealth/webpack.config.js index 0986446dc566..0276ebf5584c 100644 --- a/packages/google-cloud-servicehealth/webpack.config.js +++ b/packages/google-cloud-servicehealth/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-shell/.eslintignore b/packages/google-cloud-shell/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-shell/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-shell/.eslintrc.json b/packages/google-cloud-shell/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-shell/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-shell/README.md b/packages/google-cloud-shell/README.md index 7519ba9eb116..b60f78a29fa4 100644 --- a/packages/google-cloud-shell/README.md +++ b/packages/google-cloud-shell/README.md @@ -97,7 +97,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-shell/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`) @@ -107,7 +107,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-shell/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-shell/protos/protos.d.ts b/packages/google-cloud-shell/protos/protos.d.ts index 609a671e6fc4..13a27ba516b1 100644 --- a/packages/google-cloud-shell/protos/protos.d.ts +++ b/packages/google-cloud-shell/protos/protos.d.ts @@ -2263,6 +2263,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -2280,6 +2283,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 @@ -2980,6 +2986,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -2994,6 +3003,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 @@ -3072,6 +3084,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 { @@ -3398,6 +3522,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -3412,6 +3539,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 @@ -3736,6 +3866,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, @@ -4117,6 +4350,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -4147,6 +4381,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -4196,6 +4433,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -4330,6 +4570,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -4371,6 +4614,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 @@ -5218,6 +5464,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -5244,6 +5493,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 @@ -6178,6 +6430,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); @@ -6233,6 +6488,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[]; @@ -6453,6 +6711,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. */ @@ -6691,6 +7064,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -6713,6 +7089,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[]; @@ -7305,6 +7684,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. */ @@ -7334,6 +7719,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 @@ -7456,6 +7847,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. */ @@ -7575,8 +8076,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. */ @@ -7591,8 +8095,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. @@ -8125,6 +8632,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-shell/protos/protos.js b/packages/google-cloud-shell/protos/protos.js index 396a2d47d353..46fd26ff0804 100644 --- a/packages/google-cloud-shell/protos/protos.js +++ b/packages/google-cloud-shell/protos/protos.js @@ -5113,6 +5113,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -5147,6 +5148,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 @@ -5179,6 +5188,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; }; @@ -5230,6 +5241,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; @@ -5281,6 +5296,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; }; @@ -5323,6 +5343,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; }; @@ -5341,8 +5366,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) { @@ -5350,6 +5377,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; }; @@ -7172,6 +7201,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -7197,6 +7227,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 @@ -7223,6 +7261,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; }; @@ -7263,6 +7303,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; @@ -7303,6 +7347,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; }; @@ -7323,6 +7372,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; }; @@ -7339,10 +7393,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; }; @@ -7372,6 +7430,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; })(); @@ -8248,6 +8558,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -8259,6 +8570,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) @@ -8273,6 +8585,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 @@ -8299,6 +8619,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; }; @@ -8329,7 +8652,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) @@ -8339,6 +8662,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; @@ -8379,6 +8725,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; }; @@ -8399,6 +8753,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; }; @@ -8415,10 +8776,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; }; @@ -9057,29 +9426,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; })(); @@ -10042,6 +10656,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 @@ -10056,6 +10671,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; @@ -10080,6 +10696,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 @@ -10102,6 +10719,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -10152,6 +10770,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 @@ -10273,6 +10899,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; }; @@ -10345,6 +10974,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 = []; @@ -10447,6 +11082,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"; @@ -10501,6 +11143,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -10553,6 +11196,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"); @@ -10616,6 +11266,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -10681,6 +11335,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -10737,6 +11392,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; }; @@ -10785,6 +11445,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 */ /** @@ -10890,6 +11551,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 @@ -10942,6 +11611,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; }; @@ -11034,6 +11705,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -11147,6 +11822,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; }; @@ -11246,6 +11930,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; }; @@ -11275,6 +11979,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; @@ -11320,6 +12025,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; }; @@ -13364,6 +14071,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 */ /** @@ -13424,6 +14132,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 @@ -13461,6 +14177,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; }; @@ -13523,6 +14241,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -13591,6 +14313,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; }; @@ -13640,6 +14371,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; }; @@ -13664,6 +14415,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; @@ -13684,6 +14436,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; }; @@ -16002,6 +16756,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 @@ -16122,6 +16877,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 @@ -16196,6 +16959,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(); @@ -16297,6 +17062,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 = []; @@ -16432,6 +17201,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"; @@ -16620,6 +17394,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"); @@ -16717,6 +17496,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")) @@ -16749,6 +17529,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) @@ -17021,6 +17803,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -17062,103 +17845,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; @@ -17753,6 +19022,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 */ @@ -17796,6 +19066,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 @@ -17834,6 +19112,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(); @@ -17885,6 +19165,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 = []; @@ -17937,6 +19221,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"; @@ -17970,6 +19259,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"); @@ -18002,6 +19296,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -18009,6 +19304,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) @@ -19476,6 +20773,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 */ /** @@ -19541,6 +20840,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 @@ -19577,6 +20892,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; }; @@ -19637,6 +20956,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; @@ -19727,6 +21054,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; }; @@ -19866,6 +21213,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; }; @@ -19889,6 +21284,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; @@ -19902,6 +21299,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; }; @@ -20029,6 +21430,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; })(); @@ -20213,6 +21827,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -20230,6 +21845,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -20278,6 +21894,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -20330,6 +21950,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -20438,7 +22062,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 */ /** @@ -20465,12 +22090,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. @@ -20496,10 +22129,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; }; @@ -20540,8 +22175,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: @@ -20584,6 +22223,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -20596,10 +22236,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; }; @@ -20627,6 +22272,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -20668,10 +22317,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; }; @@ -20690,13 +22344,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; }; @@ -21911,6 +23568,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-shell/protos/protos.json b/packages/google-cloud-shell/protos/protos.json index 048e733b151c..cdc517c36b25 100644 --- a/packages/google-cloud-shell/protos/protos.json +++ b/packages/google-cloud-shell/protos/protos.json @@ -380,8 +380,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": { @@ -505,6 +504,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -645,6 +648,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 + } + } } } }, @@ -702,6 +727,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -763,6 +793,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -895,12 +938,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, @@ -939,6 +989,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1027,6 +1082,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -1252,6 +1311,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -1302,7 +1365,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -1466,6 +1536,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -1601,7 +1672,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -1629,6 +1701,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1698,6 +1774,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 + } + } } } }, @@ -1786,6 +1882,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -1928,6 +2028,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -1938,6 +2039,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -1948,6 +2050,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -1958,6 +2061,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -1968,7 +2072,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" } }, @@ -1978,27 +2083,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, @@ -2043,7 +2159,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2058,6 +2180,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 + } + } + } } } }, @@ -2085,11 +2234,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2102,6 +2266,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -2187,6 +2357,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -2236,6 +2414,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-shell/samples/generated/v1/snippet_metadata_google.cloud.shell.v1.json b/packages/google-cloud-shell/samples/generated/v1/snippet_metadata_google.cloud.shell.v1.json index 7ad99ac13c65..666e4d31baf6 100644 --- a/packages/google-cloud-shell/samples/generated/v1/snippet_metadata_google.cloud.shell.v1.json +++ b/packages/google-cloud-shell/samples/generated/v1/snippet_metadata_google.cloud.shell.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-shell", - "version": "4.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-shell/src/v1/cloud_shell_service_client.ts b/packages/google-cloud-shell/src/v1/cloud_shell_service_client.ts index 0752b1cc6bb8..e0b8d3951380 100644 --- a/packages/google-cloud-shell/src/v1/cloud_shell_service_client.ts +++ b/packages/google-cloud-shell/src/v1/cloud_shell_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, +} from 'google-gax'; 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 @@ -50,7 +57,7 @@ export class CloudShellServiceClient { 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('shell'); @@ -63,10 +70,10 @@ export class CloudShellServiceClient { 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; - cloudShellServiceStub?: Promise<{[name: string]: Function}>; + cloudShellServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudShellServiceClient. @@ -107,21 +114,42 @@ export class CloudShellServiceClient { * const client = new CloudShellServiceClient({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 CloudShellServiceClient; - 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 = 'cloudshell.' + 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; @@ -146,7 +174,7 @@ export class CloudShellServiceClient { 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; @@ -160,10 +188,7 @@ export class CloudShellServiceClient { } // 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,7 +210,7 @@ export class CloudShellServiceClient { // Create useful helper objects for these. this.pathTemplates = { environmentPathTemplate: new this._gaxModule.PathTemplate( - 'users/{user}/environments/{environment}' + 'users/{user}/environments/{environment}', ), }; @@ -195,53 +220,70 @@ export class CloudShellServiceClient { // 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 = []; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const startEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.shell.v1.StartEnvironmentResponse') as gax.protobuf.Type; + '.google.cloud.shell.v1.StartEnvironmentResponse', + ) as gax.protobuf.Type; const startEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.shell.v1.StartEnvironmentMetadata') as gax.protobuf.Type; + '.google.cloud.shell.v1.StartEnvironmentMetadata', + ) as gax.protobuf.Type; const authorizeEnvironmentResponse = protoFilesRoot.lookup( - '.google.cloud.shell.v1.AuthorizeEnvironmentResponse') as gax.protobuf.Type; + '.google.cloud.shell.v1.AuthorizeEnvironmentResponse', + ) as gax.protobuf.Type; const authorizeEnvironmentMetadata = protoFilesRoot.lookup( - '.google.cloud.shell.v1.AuthorizeEnvironmentMetadata') as gax.protobuf.Type; + '.google.cloud.shell.v1.AuthorizeEnvironmentMetadata', + ) as gax.protobuf.Type; const addPublicKeyResponse = protoFilesRoot.lookup( - '.google.cloud.shell.v1.AddPublicKeyResponse') as gax.protobuf.Type; + '.google.cloud.shell.v1.AddPublicKeyResponse', + ) as gax.protobuf.Type; const addPublicKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.shell.v1.AddPublicKeyMetadata') as gax.protobuf.Type; + '.google.cloud.shell.v1.AddPublicKeyMetadata', + ) as gax.protobuf.Type; const removePublicKeyResponse = protoFilesRoot.lookup( - '.google.cloud.shell.v1.RemovePublicKeyResponse') as gax.protobuf.Type; + '.google.cloud.shell.v1.RemovePublicKeyResponse', + ) as gax.protobuf.Type; const removePublicKeyMetadata = protoFilesRoot.lookup( - '.google.cloud.shell.v1.RemovePublicKeyMetadata') as gax.protobuf.Type; + '.google.cloud.shell.v1.RemovePublicKeyMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { startEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, startEnvironmentResponse.decode.bind(startEnvironmentResponse), - startEnvironmentMetadata.decode.bind(startEnvironmentMetadata)), + startEnvironmentMetadata.decode.bind(startEnvironmentMetadata), + ), authorizeEnvironment: new this._gaxModule.LongrunningDescriptor( this.operationsClient, authorizeEnvironmentResponse.decode.bind(authorizeEnvironmentResponse), - authorizeEnvironmentMetadata.decode.bind(authorizeEnvironmentMetadata)), + authorizeEnvironmentMetadata.decode.bind(authorizeEnvironmentMetadata), + ), addPublicKey: new this._gaxModule.LongrunningDescriptor( this.operationsClient, addPublicKeyResponse.decode.bind(addPublicKeyResponse), - addPublicKeyMetadata.decode.bind(addPublicKeyMetadata)), + addPublicKeyMetadata.decode.bind(addPublicKeyMetadata), + ), removePublicKey: new this._gaxModule.LongrunningDescriptor( this.operationsClient, removePublicKeyResponse.decode.bind(removePublicKeyResponse), - removePublicKeyMetadata.decode.bind(removePublicKeyMetadata)) + removePublicKeyMetadata.decode.bind(removePublicKeyMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.shell.v1.CloudShellService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.shell.v1.CloudShellService', + 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,37 +314,46 @@ export class CloudShellServiceClient { // Put together the "service stub" for // google.cloud.shell.v1.CloudShellService. this.cloudShellServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.shell.v1.CloudShellService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.shell.v1.CloudShellService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.shell.v1.CloudShellService, - 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 cloudShellServiceStubMethods = - ['getEnvironment', 'startEnvironment', 'authorizeEnvironment', 'addPublicKey', 'removePublicKey']; + const cloudShellServiceStubMethods = [ + 'getEnvironment', + 'startEnvironment', + 'authorizeEnvironment', + 'addPublicKey', + 'removePublicKey', + ]; for (const methodName of cloudShellServiceStubMethods) { const callPromise = this.cloudShellServiceStub.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.longrunning[methodName] || - undefined; + const descriptor = this.descriptors.longrunning[methodName] || undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -317,8 +368,14 @@ export class CloudShellServiceClient { * @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 'cloudshell.googleapis.com'; } @@ -329,8 +386,14 @@ export class CloudShellServiceClient { * @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 'cloudshell.googleapis.com'; } @@ -361,9 +424,7 @@ export class CloudShellServiceClient { * @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; @@ -372,8 +433,9 @@ export class CloudShellServiceClient { * 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; @@ -384,573 +446,855 @@ export class CloudShellServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets an environment. Returns NOT_FOUND if the environment does not exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the requested resource, for example `users/me/environments/default` - * or `users/someone@example.com/environments/default`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.shell.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/cloud_shell_service.get_environment.js - * region_tag:cloudshell_v1_generated_CloudShellService_GetEnvironment_async - */ + /** + * Gets an environment. Returns NOT_FOUND if the environment does not exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the requested resource, for example `users/me/environments/default` + * or `users/someone@example.com/environments/default`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.shell.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/cloud_shell_service.get_environment.js + * region_tag:cloudshell_v1_generated_CloudShellService_GetEnvironment_async + */ getEnvironment( - request?: protos.google.cloud.shell.v1.IGetEnvironmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.shell.v1.IGetEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.shell.v1.IEnvironment, + protos.google.cloud.shell.v1.IGetEnvironmentRequest | undefined, + {} | undefined, + ] + >; getEnvironment( - request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.shell.v1.IEnvironment, + protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, - callback: Callback< - protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, + callback: Callback< + protos.google.cloud.shell.v1.IEnvironment, + protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, + {} | null | undefined + >, + ): void; getEnvironment( - request?: protos.google.cloud.shell.v1.IGetEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.shell.v1.IGetEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.shell.v1.IGetEnvironmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.shell.v1.IEnvironment, + protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.shell.v1.IEnvironment, + protos.google.cloud.shell.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.shell.v1.IEnvironment, - protos.google.cloud.shell.v1.IGetEnvironmentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.shell.v1.IEnvironment, + | protos.google.cloud.shell.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.shell.v1.IEnvironment, - protos.google.cloud.shell.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.shell.v1.IEnvironment, + protos.google.cloud.shell.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; }); } -/** - * Starts an existing environment, allowing clients to connect to it. The - * returned operation will contain an instance of StartEnvironmentMetadata in - * its metadata field. Users can wait for the environment to start by polling - * this operation via GetOperation. Once the environment has finished starting - * and is ready to accept connections, the operation will contain a - * StartEnvironmentResponse in its response field. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Name of the resource that should be started, for example - * `users/me/environments/default` or - * `users/someone@example.com/environments/default`. - * @param {string} request.accessToken - * The initial access token passed to the environment. If this is present and - * valid, the environment will be pre-authenticated with gcloud so that the - * user can run gcloud commands in Cloud Shell without having to log in. This - * code can be updated later by calling AuthorizeEnvironment. - * @param {string[]} request.publicKeys - * Public keys that should be added to the environment before it is started. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://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_shell_service.start_environment.js - * region_tag:cloudshell_v1_generated_CloudShellService_StartEnvironment_async - */ + /** + * Starts an existing environment, allowing clients to connect to it. The + * returned operation will contain an instance of StartEnvironmentMetadata in + * its metadata field. Users can wait for the environment to start by polling + * this operation via GetOperation. Once the environment has finished starting + * and is ready to accept connections, the operation will contain a + * StartEnvironmentResponse in its response field. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Name of the resource that should be started, for example + * `users/me/environments/default` or + * `users/someone@example.com/environments/default`. + * @param {string} request.accessToken + * The initial access token passed to the environment. If this is present and + * valid, the environment will be pre-authenticated with gcloud so that the + * user can run gcloud commands in Cloud Shell without having to log in. This + * code can be updated later by calling AuthorizeEnvironment. + * @param {string[]} request.publicKeys + * Public keys that should be added to the environment before it is started. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://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_shell_service.start_environment.js + * region_tag:cloudshell_v1_generated_CloudShellService_StartEnvironment_async + */ startEnvironment( - request?: protos.google.cloud.shell.v1.IStartEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.shell.v1.IStartEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; startEnvironment( - request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startEnvironment( - request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; startEnvironment( - request?: protos.google.cloud.shell.v1.IStartEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.shell.v1.IStartEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('startEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('startEnvironment request %j', request); - return this.innerApiCalls.startEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('startEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .startEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('startEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `startEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://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_shell_service.start_environment.js - * region_tag:cloudshell_v1_generated_CloudShellService_StartEnvironment_async - */ - async checkStartEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `startEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://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_shell_service.start_environment.js + * region_tag:cloudshell_v1_generated_CloudShellService_StartEnvironment_async + */ + async checkStartEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.shell.v1.StartEnvironmentResponse, + protos.google.cloud.shell.v1.StartEnvironmentMetadata + > + > { this._log.info('startEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.startEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.startEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.shell.v1.StartEnvironmentResponse, + protos.google.cloud.shell.v1.StartEnvironmentMetadata + >; } -/** - * Sends OAuth credentials to a running environment on behalf of a user. When - * this completes, the environment will be authorized to run various Google - * Cloud command line tools without requiring the user to manually - * authenticate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Name of the resource that should receive the credentials, for example - * `users/me/environments/default` or - * `users/someone@example.com/environments/default`. - * @param {string} request.accessToken - * The OAuth access token that should be sent to the environment. - * @param {string} request.idToken - * The OAuth ID token that should be sent to the environment. - * @param {google.protobuf.Timestamp} request.expireTime - * The time when the credentials expire. If not set, defaults to one hour from - * when the server received 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://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_shell_service.authorize_environment.js - * region_tag:cloudshell_v1_generated_CloudShellService_AuthorizeEnvironment_async - */ + /** + * Sends OAuth credentials to a running environment on behalf of a user. When + * this completes, the environment will be authorized to run various Google + * Cloud command line tools without requiring the user to manually + * authenticate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Name of the resource that should receive the credentials, for example + * `users/me/environments/default` or + * `users/someone@example.com/environments/default`. + * @param {string} request.accessToken + * The OAuth access token that should be sent to the environment. + * @param {string} request.idToken + * The OAuth ID token that should be sent to the environment. + * @param {google.protobuf.Timestamp} request.expireTime + * The time when the credentials expire. If not set, defaults to one hour from + * when the server received 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://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_shell_service.authorize_environment.js + * region_tag:cloudshell_v1_generated_CloudShellService_AuthorizeEnvironment_async + */ authorizeEnvironment( - request?: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; authorizeEnvironment( - request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; authorizeEnvironment( - request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; authorizeEnvironment( - request?: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('authorizeEnvironment response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('authorizeEnvironment request %j', request); - return this.innerApiCalls.authorizeEnvironment(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('authorizeEnvironment response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .authorizeEnvironment(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('authorizeEnvironment response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `authorizeEnvironment()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://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_shell_service.authorize_environment.js - * region_tag:cloudshell_v1_generated_CloudShellService_AuthorizeEnvironment_async - */ - async checkAuthorizeEnvironmentProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `authorizeEnvironment()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://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_shell_service.authorize_environment.js + * region_tag:cloudshell_v1_generated_CloudShellService_AuthorizeEnvironment_async + */ + async checkAuthorizeEnvironmentProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.shell.v1.AuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.AuthorizeEnvironmentMetadata + > + > { this._log.info('authorizeEnvironment long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.authorizeEnvironment, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.authorizeEnvironment, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.shell.v1.AuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.AuthorizeEnvironmentMetadata + >; } -/** - * Adds a public SSH key to an environment, allowing clients with the - * corresponding private key to connect to that environment via SSH. If a key - * with the same content already exists, this will error with ALREADY_EXISTS. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Environment this key should be added to, e.g. - * `users/me/environments/default`. - * @param {string} request.key - * Key that should be added to the environment. Supported formats are - * `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256` - * (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and - * `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as - * <format> <content>, where <content> part is encoded with - * Base64. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://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_shell_service.add_public_key.js - * region_tag:cloudshell_v1_generated_CloudShellService_AddPublicKey_async - */ + /** + * Adds a public SSH key to an environment, allowing clients with the + * corresponding private key to connect to that environment via SSH. If a key + * with the same content already exists, this will error with ALREADY_EXISTS. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Environment this key should be added to, e.g. + * `users/me/environments/default`. + * @param {string} request.key + * Key that should be added to the environment. Supported formats are + * `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256` + * (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and + * `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as + * <format> <content>, where <content> part is encoded with + * Base64. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://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_shell_service.add_public_key.js + * region_tag:cloudshell_v1_generated_CloudShellService_AddPublicKey_async + */ addPublicKey( - request?: protos.google.cloud.shell.v1.IAddPublicKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.shell.v1.IAddPublicKeyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; addPublicKey( - request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; addPublicKey( - request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; addPublicKey( - request?: protos.google.cloud.shell.v1.IAddPublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.shell.v1.IAddPublicKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + environment: request.environment ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().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.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('addPublicKey response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('addPublicKey request %j', request); - return this.innerApiCalls.addPublicKey(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('addPublicKey response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .addPublicKey(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('addPublicKey response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `addPublicKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://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_shell_service.add_public_key.js - * region_tag:cloudshell_v1_generated_CloudShellService_AddPublicKey_async - */ - async checkAddPublicKeyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `addPublicKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://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_shell_service.add_public_key.js + * region_tag:cloudshell_v1_generated_CloudShellService_AddPublicKey_async + */ + async checkAddPublicKeyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.shell.v1.AddPublicKeyResponse, + protos.google.cloud.shell.v1.AddPublicKeyMetadata + > + > { this._log.info('addPublicKey long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.addPublicKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.addPublicKey, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.shell.v1.AddPublicKeyResponse, + protos.google.cloud.shell.v1.AddPublicKeyMetadata + >; } -/** - * Removes a public SSH key from an environment. Clients will no longer be - * able to connect to the environment using the corresponding private key. - * If a key with the same content is not present, this will error with - * NOT_FOUND. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.environment - * Environment this key should be removed from, e.g. - * `users/me/environments/default`. - * @param {string} request.key - * Key that should be removed from the environment. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://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_shell_service.remove_public_key.js - * region_tag:cloudshell_v1_generated_CloudShellService_RemovePublicKey_async - */ + /** + * Removes a public SSH key from an environment. Clients will no longer be + * able to connect to the environment using the corresponding private key. + * If a key with the same content is not present, this will error with + * NOT_FOUND. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.environment + * Environment this key should be removed from, e.g. + * `users/me/environments/default`. + * @param {string} request.key + * Key that should be removed from the environment. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://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_shell_service.remove_public_key.js + * region_tag:cloudshell_v1_generated_CloudShellService_RemovePublicKey_async + */ removePublicKey( - request?: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; removePublicKey( - request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removePublicKey( - request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, + callback: Callback< + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; removePublicKey( - request?: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'environment': request.environment ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + environment: request.environment ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().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.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('removePublicKey response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('removePublicKey request %j', request); - return this.innerApiCalls.removePublicKey(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('removePublicKey response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .removePublicKey(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('removePublicKey response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `removePublicKey()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://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_shell_service.remove_public_key.js - * region_tag:cloudshell_v1_generated_CloudShellService_RemovePublicKey_async - */ - async checkRemovePublicKeyProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `removePublicKey()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://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_shell_service.remove_public_key.js + * region_tag:cloudshell_v1_generated_CloudShellService_RemovePublicKey_async + */ + async checkRemovePublicKeyProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.shell.v1.RemovePublicKeyResponse, + protos.google.cloud.shell.v1.RemovePublicKeyMetadata + > + > { this._log.info('removePublicKey long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.removePublicKey, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.removePublicKey, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.shell.v1.RemovePublicKeyResponse, + protos.google.cloud.shell.v1.RemovePublicKeyMetadata + >; } -/** + /** * 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. @@ -993,22 +1337,22 @@ export class CloudShellServiceClient { 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); } /** @@ -1043,15 +1387,15 @@ export class CloudShellServiceClient { */ 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); } /** @@ -1085,7 +1429,7 @@ export class CloudShellServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1098,25 +1442,24 @@ export class CloudShellServiceClient { 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 @@ -1155,22 +1498,22 @@ export class CloudShellServiceClient { 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); } @@ -1185,7 +1528,7 @@ export class CloudShellServiceClient { * @param {string} environment * @returns {string} Resource name string. */ - environmentPath(user:string,environment:string) { + environmentPath(user: string, environment: string) { return this.pathTemplates.environmentPathTemplate.render({ user: user, environment: environment, @@ -1200,7 +1543,8 @@ export class CloudShellServiceClient { * @returns {string} A string representing the user. */ matchUserFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).user; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .user; } /** @@ -1211,7 +1555,8 @@ export class CloudShellServiceClient { * @returns {string} A string representing the environment. */ matchEnvironmentFromEnvironmentName(environmentName: string) { - return this.pathTemplates.environmentPathTemplate.match(environmentName).environment; + return this.pathTemplates.environmentPathTemplate.match(environmentName) + .environment; } /** @@ -1222,7 +1567,7 @@ export class CloudShellServiceClient { */ close(): Promise { if (this.cloudShellServiceStub && !this._terminated) { - return this.cloudShellServiceStub.then(stub => { + return this.cloudShellServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1231,4 +1576,4 @@ export class CloudShellServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-shell/src/v1/index.ts b/packages/google-cloud-shell/src/v1/index.ts index ca39f06531c9..b042882397d2 100644 --- a/packages/google-cloud-shell/src/v1/index.ts +++ b/packages/google-cloud-shell/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudShellServiceClient} from './cloud_shell_service_client'; +export { CloudShellServiceClient } from './cloud_shell_service_client'; diff --git a/packages/google-cloud-shell/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-shell/system-test/fixtures/sample/src/index.ts index 802abedfe3b9..958c426ff0e3 100644 --- a/packages/google-cloud-shell/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-shell/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 {CloudShellServiceClient} from '@google-cloud/shell'; +import { CloudShellServiceClient } from '@google-cloud/shell'; // check that the client class type name can be used function doStuffWithCloudShellServiceClient(client: CloudShellServiceClient) { diff --git a/packages/google-cloud-shell/system-test/install.ts b/packages/google-cloud-shell/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-shell/system-test/install.ts +++ b/packages/google-cloud-shell/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-shell/test/gapic_cloud_shell_service_v1.ts b/packages/google-cloud-shell/test/gapic_cloud_shell_service_v1.ts index 16025b637272..28c660ccd0b8 100644 --- a/packages/google-cloud-shell/test/gapic_cloud_shell_service_v1.ts +++ b/packages/google-cloud-shell/test/gapic_cloud_shell_service_v1.ts @@ -19,1252 +19,1564 @@ 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 cloudshellserviceModule from '../src'; -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 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.CloudShellServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudshell.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient(); - 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 = cloudshellserviceModule.v1.CloudShellServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudshell.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudshellserviceModule.v1.CloudShellServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudshell.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudshell.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudshell.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudshell.googleapis.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 cloudshellserviceModule.v1.CloudShellServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudshell.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 cloudshellserviceModule.v1.CloudShellServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudshell.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 cloudshellserviceModule.v1.CloudShellServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = cloudshellserviceModule.v1.CloudShellServiceClient.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 = + cloudshellserviceModule.v1.CloudShellServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudshell.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudshellserviceModule.v1.CloudShellServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudshell.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudshell.example.com'); + }); - it('should create a client with no option', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient(); - assert(client); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudshell.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudshell.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudShellServiceStub, undefined); - await client.initialize(); - assert(client.cloudShellServiceStub); + 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 cloudshellserviceModule.v1.CloudShellServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudshell.configured.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 initialized client', done => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudShellServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new cloudshellserviceModule.v1.CloudShellServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudShellServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = cloudshellserviceModule.v1.CloudShellServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + fallback: true, + }); + assert(client); }); - describe('getEnvironment', () => { - it('invokes getEnvironment without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.shell.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('has initialize method and supports deferred initialization', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudShellServiceStub, undefined); + await client.initialize(); + assert(client.cloudShellServiceStub); + }); - it('invokes getEnvironment without error using callback', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.GetEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.shell.v1.Environment() - ); - client.innerApiCalls.getEnvironment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getEnvironment( - request, - (err?: Error|null, result?: protos.google.cloud.shell.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('has close method for the initialized client', (done) => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudShellServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getEnvironment with error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.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('has close method for the non-initialized client', (done) => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudShellServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getEnvironment with closed client', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.GetEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.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 getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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('startEnvironment', () => { - it('invokes startEnvironment without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.StartEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.StartEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.startEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startEnvironment 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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('getEnvironment', () => { + it('invokes getEnvironment without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.shell.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 startEnvironment without error using callback', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.StartEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.StartEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.startEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startEnvironment 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.GetEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.shell.v1.Environment(), + ); + client.innerApiCalls.getEnvironment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getEnvironment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.shell.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 startEnvironment with call error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.StartEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.StartEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.startEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.startEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startEnvironment 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.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 startEnvironment with LRO error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.StartEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.StartEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.startEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.startEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startEnvironment 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.GetEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.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('startEnvironment', () => { + it('invokes startEnvironment without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.StartEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.StartEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.startEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartEnvironmentProgress without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkStartEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes startEnvironment without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.StartEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.StartEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.startEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.shell.v1.IStartEnvironmentResponse, + protos.google.cloud.shell.v1.IStartEnvironmentMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkStartEnvironmentProgress with error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkStartEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes startEnvironment with call error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.StartEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.StartEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.startEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('authorizeEnvironment', () => { - it('invokes authorizeEnvironment without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AuthorizeEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.authorizeEnvironment = stubLongRunningCall(expectedResponse); - const [operation] = await client.authorizeEnvironment(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startEnvironment with LRO error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.StartEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.StartEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.startEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes authorizeEnvironment without error using callback', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AuthorizeEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.authorizeEnvironment = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.authorizeEnvironment( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartEnvironmentProgress without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkStartEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes authorizeEnvironment with call error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AuthorizeEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.authorizeEnvironment = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.authorizeEnvironment(request), expectedError); - const actualRequest = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkStartEnvironmentProgress with error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkStartEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('authorizeEnvironment', () => { + it('invokes authorizeEnvironment without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AuthorizeEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.authorizeEnvironment = + stubLongRunningCall(expectedResponse); + const [operation] = await client.authorizeEnvironment(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes authorizeEnvironment with LRO error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AuthorizeEnvironmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.authorizeEnvironment = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.authorizeEnvironment(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.authorizeEnvironment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes authorizeEnvironment without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AuthorizeEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.authorizeEnvironment = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.authorizeEnvironment( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, + protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAuthorizeEnvironmentProgress without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAuthorizeEnvironmentProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes authorizeEnvironment with call error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AuthorizeEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.authorizeEnvironment = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.authorizeEnvironment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAuthorizeEnvironmentProgress with error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAuthorizeEnvironmentProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes authorizeEnvironment with LRO error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AuthorizeEnvironmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AuthorizeEnvironmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.authorizeEnvironment = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.authorizeEnvironment(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.authorizeEnvironment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('addPublicKey', () => { - it('invokes addPublicKey without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AddPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AddPublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.addPublicKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.addPublicKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAuthorizeEnvironmentProgress without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAuthorizeEnvironmentProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes addPublicKey without error using callback', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AddPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AddPublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.addPublicKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addPublicKey( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAuthorizeEnvironmentProgress with error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkAuthorizeEnvironmentProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('addPublicKey', () => { + it('invokes addPublicKey without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AddPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AddPublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.addPublicKey = stubLongRunningCall(expectedResponse); + const [operation] = await client.addPublicKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addPublicKey with call error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AddPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AddPublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addPublicKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.addPublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addPublicKey without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AddPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AddPublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.addPublicKey = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addPublicKey( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.shell.v1.IAddPublicKeyResponse, + protos.google.cloud.shell.v1.IAddPublicKeyMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addPublicKey with LRO error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.AddPublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.AddPublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addPublicKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.addPublicKey(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addPublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addPublicKey with call error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AddPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AddPublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addPublicKey = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.addPublicKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAddPublicKeyProgress without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkAddPublicKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes addPublicKey with LRO error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.AddPublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.AddPublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addPublicKey = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.addPublicKey(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkAddPublicKeyProgress with error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkAddPublicKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkAddPublicKeyProgress without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkAddPublicKeyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('removePublicKey', () => { - it('invokes removePublicKey without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.RemovePublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.RemovePublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removePublicKey = stubLongRunningCall(expectedResponse); - const [operation] = await client.removePublicKey(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkAddPublicKeyProgress with error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkAddPublicKeyProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('removePublicKey', () => { + it('invokes removePublicKey without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.RemovePublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.RemovePublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removePublicKey = + stubLongRunningCall(expectedResponse); + const [operation] = await client.removePublicKey(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removePublicKey without error using callback', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.RemovePublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.RemovePublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.removePublicKey = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.removePublicKey( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removePublicKey without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.RemovePublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.RemovePublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.removePublicKey = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.removePublicKey( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.shell.v1.IRemovePublicKeyResponse, + protos.google.cloud.shell.v1.IRemovePublicKeyMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removePublicKey with call error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.RemovePublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.RemovePublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removePublicKey = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.removePublicKey(request), expectedError); - const actualRequest = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removePublicKey with call error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.RemovePublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.RemovePublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removePublicKey = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.removePublicKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes removePublicKey with LRO error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.shell.v1.RemovePublicKeyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.shell.v1.RemovePublicKeyRequest', ['environment']); - request.environment = defaultValue1; - const expectedHeaderRequestParams = `environment=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.removePublicKey = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.removePublicKey(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.removePublicKey as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes removePublicKey with LRO error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.shell.v1.RemovePublicKeyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.shell.v1.RemovePublicKeyRequest', + ['environment'], + ); + request.environment = defaultValue1; + const expectedHeaderRequestParams = `environment=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.removePublicKey = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.removePublicKey(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.removePublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkRemovePublicKeyProgress without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRemovePublicKeyProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkRemovePublicKeyProgress without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRemovePublicKeyProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkRemovePublicKeyProgress with error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRemovePublicKeyProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRemovePublicKeyProgress with error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkRemovePublicKeyProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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)); - }); + it('invokes getOperation without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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)); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 getOperation with error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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 cloudshellserviceModule.v1.CloudShellServiceClient({ - 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('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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), + ); }); - - describe('Path templates', () => { - - describe('environment', async () => { - const fakePath = "/rendered/path/environment"; - const expectedParameters = { - user: "userValue", - environment: "environmentValue", - }; - const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ - 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("userValue", "environmentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.environmentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchUserFromEnvironmentName', () => { - const result = client.matchUserFromEnvironmentName(fakePath); - assert.strictEqual(result, "userValue"); - 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)); - }); - }); + it('invokes cancelOperation without error using callback', async () => { + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 cloudshellserviceModule.v1.CloudShellServiceClient({ + 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 = { + user: 'userValue', + environment: 'environmentValue', + }; + const client = new cloudshellserviceModule.v1.CloudShellServiceClient({ + 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('userValue', 'environmentValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.environmentPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchUserFromEnvironmentName', () => { + const result = client.matchUserFromEnvironmentName(fakePath); + assert.strictEqual(result, 'userValue'); + 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), + ); + }); }); + }); }); diff --git a/packages/google-cloud-shell/webpack.config.js b/packages/google-cloud-shell/webpack.config.js index 2d7047889bef..b7f826274bb1 100644 --- a/packages/google-cloud-shell/webpack.config.js +++ b/packages/google-cloud-shell/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-speech/.eslintignore b/packages/google-cloud-speech/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-speech/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-speech/.eslintrc.json b/packages/google-cloud-speech/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-speech/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-speech/README.md b/packages/google-cloud-speech/README.md index ef9d52985b1c..01302dc57cc7 100644 --- a/packages/google-cloud-speech/README.md +++ b/packages/google-cloud-speech/README.md @@ -143,7 +143,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-speech/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`) @@ -153,7 +153,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-speech/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-speech/protos/protos.d.ts b/packages/google-cloud-speech/protos/protos.d.ts index 13e582d52919..3fa1b1f4cf39 100644 --- a/packages/google-cloud-speech/protos/protos.d.ts +++ b/packages/google-cloud-speech/protos/protos.d.ts @@ -19438,6 +19438,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -19455,6 +19458,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 @@ -20155,6 +20161,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -20169,6 +20178,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 @@ -20247,6 +20259,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 { @@ -20573,6 +20697,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -20587,6 +20714,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 @@ -20911,6 +21041,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, @@ -21193,6 +21426,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. */ @@ -21207,6 +21443,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 @@ -21296,6 +21535,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. */ @@ -21401,6 +21737,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -21431,6 +21768,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -21480,6 +21820,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -21614,6 +21957,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -21655,6 +22001,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 @@ -22502,6 +22851,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -22528,6 +22880,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 @@ -23462,6 +23817,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); @@ -23520,6 +23878,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[]; @@ -23740,6 +24101,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. */ @@ -23978,6 +24454,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -24000,6 +24479,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[]; @@ -24592,6 +25074,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. */ @@ -24621,6 +25109,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 @@ -24743,6 +25237,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. */ @@ -24862,8 +25466,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. */ @@ -24878,8 +25485,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. @@ -25412,6 +26022,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-speech/protos/protos.js b/packages/google-cloud-speech/protos/protos.js index 9ee4dd311637..b484a179bf75 100644 --- a/packages/google-cloud-speech/protos/protos.js +++ b/packages/google-cloud-speech/protos/protos.js @@ -48362,6 +48362,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -48396,6 +48397,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 @@ -48428,6 +48437,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; }; @@ -48479,6 +48490,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; @@ -48530,6 +48545,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; }; @@ -48572,6 +48592,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; }; @@ -48590,8 +48615,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) { @@ -48599,6 +48626,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; }; @@ -50421,6 +50450,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -50446,6 +50476,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 @@ -50472,6 +50510,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; }; @@ -50512,6 +50552,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; @@ -50552,6 +50596,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; }; @@ -50572,6 +50621,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; }; @@ -50588,10 +50642,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; }; @@ -50621,6 +50679,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; })(); @@ -51497,6 +51807,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -51508,6 +51819,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) @@ -51522,6 +51834,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 @@ -51548,6 +51868,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; }; @@ -51578,7 +51901,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) @@ -51588,6 +51911,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; @@ -51628,6 +51974,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; }; @@ -51648,6 +52002,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; }; @@ -51664,10 +52025,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; }; @@ -52306,29 +52675,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; })(); @@ -53055,6 +53669,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -53066,6 +53681,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) @@ -53080,6 +53696,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 @@ -53106,6 +53730,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; }; @@ -53146,6 +53773,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; @@ -53192,6 +53825,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; }; @@ -53235,6 +53877,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; }; @@ -53251,10 +53903,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; }; @@ -53307,37 +53966,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) @@ -53345,80 +53991,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: @@ -53430,37 +54073,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; } @@ -53550,6 +54414,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 @@ -53564,6 +54429,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; @@ -53588,6 +54454,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 @@ -53610,6 +54477,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -53660,6 +54528,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 @@ -53781,6 +54657,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; }; @@ -53853,6 +54732,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 = []; @@ -53955,6 +54840,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"; @@ -54009,6 +54901,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -54061,6 +54954,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"); @@ -54124,6 +55024,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -54189,6 +55093,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -54245,6 +55150,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; }; @@ -54293,6 +55203,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 */ /** @@ -54398,6 +55309,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 @@ -54450,6 +55369,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; }; @@ -54542,6 +55463,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -54655,6 +55580,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; }; @@ -54754,6 +55688,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; }; @@ -54783,6 +55737,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; @@ -54828,6 +55783,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; }; @@ -56872,6 +57829,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 */ /** @@ -56932,6 +57890,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 @@ -56969,6 +57935,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; }; @@ -57031,6 +57999,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -57099,9 +58071,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 @@ -57148,6 +58129,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; }; @@ -57172,6 +58173,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; @@ -57192,6 +58194,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; }; @@ -59510,6 +60514,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 @@ -59631,6 +60636,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 @@ -59713,6 +60726,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(); @@ -59816,6 +60831,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 = []; @@ -59955,6 +60974,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"; @@ -60148,6 +61172,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"); @@ -60250,6 +61279,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; } @@ -60283,6 +61313,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) @@ -60557,6 +61589,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -60598,103 +61631,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; @@ -61289,6 +62808,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 */ @@ -61332,6 +62852,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 @@ -61370,6 +62898,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(); @@ -61421,6 +62951,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 = []; @@ -61473,6 +63007,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"; @@ -61506,6 +63045,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"); @@ -61538,6 +63082,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -61545,6 +63090,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) @@ -63012,6 +64559,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 */ /** @@ -63077,6 +64626,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 @@ -63113,6 +64678,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; }; @@ -63173,6 +64742,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; @@ -63263,6 +64840,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; }; @@ -63402,6 +64999,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; }; @@ -63425,6 +65070,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; @@ -63438,6 +65085,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; }; @@ -63565,6 +65216,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; })(); @@ -63749,6 +65613,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -63766,6 +65631,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -63814,6 +65680,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -63866,6 +65736,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -63974,7 +65848,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 */ /** @@ -64001,12 +65876,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. @@ -64032,10 +65915,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; }; @@ -64076,8 +65961,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: @@ -64120,6 +66009,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -64132,10 +66022,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; }; @@ -64163,6 +66058,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -64204,10 +66103,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; }; @@ -64226,13 +66130,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; }; @@ -65447,6 +67354,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-speech/protos/protos.json b/packages/google-cloud-speech/protos/protos.json index f89db87a0cf6..0bc470aa2173 100644 --- a/packages/google-cloud-speech/protos/protos.json +++ b/packages/google-cloud-speech/protos/protos.json @@ -5038,8 +5038,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": { "http": { @@ -5163,6 +5162,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -5303,6 +5306,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 + } + } } } }, @@ -5360,6 +5385,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -5421,6 +5451,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -5542,6 +5585,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -5555,6 +5603,14 @@ } } } + }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } } } }, @@ -5577,12 +5633,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, @@ -5621,6 +5684,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -5709,6 +5777,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -5934,6 +6006,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -5984,7 +6060,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -6148,6 +6231,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -6283,7 +6367,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -6311,6 +6396,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6380,6 +6469,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 + } + } } } }, @@ -6468,6 +6577,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6610,6 +6723,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -6620,6 +6734,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -6630,6 +6745,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -6640,6 +6756,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -6650,7 +6767,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" } }, @@ -6660,27 +6778,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, @@ -6725,7 +6854,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -6740,6 +6875,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 + } + } + } } } }, @@ -6767,11 +6929,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -6784,6 +6961,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -6869,6 +7052,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -6999,6 +7190,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-speech/samples/generated/v1/snippet_metadata_google.cloud.speech.v1.json b/packages/google-cloud-speech/samples/generated/v1/snippet_metadata_google.cloud.speech.v1.json index dac0dd04f1f9..dee670aa1b68 100644 --- a/packages/google-cloud-speech/samples/generated/v1/snippet_metadata_google.cloud.speech.v1.json +++ b/packages/google-cloud-speech/samples/generated/v1/snippet_metadata_google.cloud.speech.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-speech", - "version": "7.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-speech/samples/generated/v1p1beta1/snippet_metadata_google.cloud.speech.v1p1beta1.json b/packages/google-cloud-speech/samples/generated/v1p1beta1/snippet_metadata_google.cloud.speech.v1p1beta1.json index 21e15e84b540..c50b1efcefdd 100644 --- a/packages/google-cloud-speech/samples/generated/v1p1beta1/snippet_metadata_google.cloud.speech.v1p1beta1.json +++ b/packages/google-cloud-speech/samples/generated/v1p1beta1/snippet_metadata_google.cloud.speech.v1p1beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-speech", - "version": "7.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-speech/samples/generated/v2/snippet_metadata_google.cloud.speech.v2.json b/packages/google-cloud-speech/samples/generated/v2/snippet_metadata_google.cloud.speech.v2.json index 7071d5a47c1c..544187db9938 100644 --- a/packages/google-cloud-speech/samples/generated/v2/snippet_metadata_google.cloud.speech.v2.json +++ b/packages/google-cloud-speech/samples/generated/v2/snippet_metadata_google.cloud.speech.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-speech", - "version": "7.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-speech/src/v1/adaptation_client.ts b/packages/google-cloud-speech/src/v1/adaptation_client.ts index 53edbf66f8fe..2f0a03ab728d 100644 --- a/packages/google-cloud-speech/src/v1/adaptation_client.ts +++ b/packages/google-cloud-speech/src/v1/adaptation_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class AdaptationClient { 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('speech'); @@ -57,9 +64,9 @@ export class AdaptationClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - adaptationStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + adaptationStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AdaptationClient. @@ -100,21 +107,42 @@ export class AdaptationClient { * const client = new AdaptationClient({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 AdaptationClient; - 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 = 'speech.' + 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; @@ -139,7 +167,7 @@ export class AdaptationClient { 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; @@ -153,10 +181,7 @@ export class AdaptationClient { } // 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 { @@ -178,16 +203,16 @@ export class AdaptationClient { // Create useful helper objects for these. this.pathTemplates = { customClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/customClasses/{custom_class}' + 'projects/{project}/locations/{location}/customClasses/{custom_class}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -195,16 +220,25 @@ export class AdaptationClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listPhraseSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'phraseSets'), - listCustomClasses: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customClasses') + listPhraseSet: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'phraseSets', + ), + listCustomClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'customClasses', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1.Adaptation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.speech.v1.Adaptation', + 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 @@ -235,37 +269,51 @@ export class AdaptationClient { // Put together the "service stub" for // google.cloud.speech.v1.Adaptation. this.adaptationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Adaptation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v1.Adaptation', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.speech.v1.Adaptation, - 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 adaptationStubMethods = - ['createPhraseSet', 'getPhraseSet', 'listPhraseSet', 'updatePhraseSet', 'deletePhraseSet', 'createCustomClass', 'getCustomClass', 'listCustomClasses', 'updateCustomClass', 'deleteCustomClass']; + const adaptationStubMethods = [ + 'createPhraseSet', + 'getPhraseSet', + 'listPhraseSet', + 'updatePhraseSet', + 'deletePhraseSet', + 'createCustomClass', + 'getCustomClass', + 'listCustomClasses', + 'updateCustomClass', + 'deleteCustomClass', + ]; for (const methodName of adaptationStubMethods) { const callPromise = this.adaptationStub.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; @@ -280,8 +328,14 @@ export class AdaptationClient { * @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 'speech.googleapis.com'; } @@ -292,8 +346,14 @@ export class AdaptationClient { * @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 'speech.googleapis.com'; } @@ -324,9 +384,7 @@ export class AdaptationClient { * @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; @@ -335,8 +393,9 @@ export class AdaptationClient { * 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; @@ -347,937 +406,1242 @@ export class AdaptationClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Create a set of phrase hints. Each item in the set can be a single word or - * a multi-word phrase. The items in the PhraseSet are favored by the - * recognition model when you send a call that includes the PhraseSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this phrase set will be created. - * Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.phraseSetId - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1.PhraseSet} request.phraseSet - * Required. The phrase set to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. - * Please see the {@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/adaptation.create_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_CreatePhraseSet_async - */ + /** + * Create a set of phrase hints. Each item in the set can be a single word or + * a multi-word phrase. The items in the PhraseSet are favored by the + * recognition model when you send a call that includes the PhraseSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this phrase set will be created. + * Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.phraseSetId + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1.PhraseSet} request.phraseSet + * Required. The phrase set to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. + * Please see the {@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/adaptation.create_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_CreatePhraseSet_async + */ createPhraseSet( - request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | undefined, + {} | undefined, + ] + >; createPhraseSet( - request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1.ICreatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createPhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.IPhraseSet, + | protos.google.cloud.speech.v1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createPhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createPhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.ICreatePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('createPhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.ICreatePhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createPhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the phrase set to retrieve. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. - * Please see the {@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/adaptation.get_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_GetPhraseSet_async - */ + /** + * Get a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to retrieve. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. + * Please see the {@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/adaptation.get_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_GetPhraseSet_async + */ getPhraseSet( - request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + >; getPhraseSet( - request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.IGetPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v1.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getPhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IGetPhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IGetPhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.PhraseSet} request.phraseSet - * Required. The phrase set to update. - * - * The phrase set's `name` field is used to identify the set to be - * updated. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields 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 {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. - * Please see the {@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/adaptation.update_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_UpdatePhraseSet_async - */ + /** + * Update a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.PhraseSet} request.phraseSet + * Required. The phrase set to update. + * + * The phrase set's `name` field is used to identify the set to be + * updated. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields 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 {@link protos.google.cloud.speech.v1.PhraseSet|PhraseSet}. + * Please see the {@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/adaptation.update_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_UpdatePhraseSet_async + */ updatePhraseSet( - request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | undefined, + {} | undefined, + ] + >; updatePhraseSet( - request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1.IUpdatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'phrase_set.name': request.phraseSet!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updatePhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.IPhraseSet, + | protos.google.cloud.speech.v1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updatePhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updatePhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.IPhraseSet, - protos.google.cloud.speech.v1.IUpdatePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('updatePhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updatePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.IPhraseSet, + protos.google.cloud.speech.v1.IUpdatePhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updatePhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Delete a phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the phrase set to delete. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/adaptation.delete_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_DeletePhraseSet_async - */ + /** + * Delete a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to delete. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/adaptation.delete_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_DeletePhraseSet_async + */ deletePhraseSet( - request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | undefined, + {} | undefined, + ] + >; deletePhraseSet( - request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.IDeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deletePhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deletePhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deletePhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeletePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('deletePhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deletePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeletePhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deletePhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Create a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this custom class will be created. - * Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.customClassId - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1.CustomClass} request.customClass - * Required. The custom class to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. - * Please see the {@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/adaptation.create_custom_class.js - * region_tag:speech_v1_generated_Adaptation_CreateCustomClass_async - */ + /** + * Create a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this custom class will be created. + * Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.customClassId + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1.CustomClass} request.customClass + * Required. The custom class to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. + * Please see the {@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/adaptation.create_custom_class.js + * region_tag:speech_v1_generated_Adaptation_CreateCustomClass_async + */ createCustomClass( - request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest | undefined, + {} | undefined, + ] + >; createCustomClass( - request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.ICreateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.ICreateCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.ICreateCustomClassRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the custom class to retrieve. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. - * Please see the {@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/adaptation.get_custom_class.js - * region_tag:speech_v1_generated_Adaptation_GetCustomClass_async - */ + /** + * Get a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to retrieve. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. + * Please see the {@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/adaptation.get_custom_class.js + * region_tag:speech_v1_generated_Adaptation_GetCustomClass_async + */ getCustomClass( - request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | undefined, + {} | undefined, + ] + >; getCustomClass( - request: protos.google.cloud.speech.v1.IGetCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request: protos.google.cloud.speech.v1.IGetCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.IGetCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IGetCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IGetCustomClassRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.CustomClass} request.customClass - * Required. The custom class to update. - * - * The custom class's `name` field is used to identify the custom class to be - * updated. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields 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 {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. - * Please see the {@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/adaptation.update_custom_class.js - * region_tag:speech_v1_generated_Adaptation_UpdateCustomClass_async - */ + /** + * Update a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.CustomClass} request.customClass + * Required. The custom class to update. + * + * The custom class's `name` field is used to identify the custom class to be + * updated. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields 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 {@link protos.google.cloud.speech.v1.CustomClass|CustomClass}. + * Please see the {@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/adaptation.update_custom_class.js + * region_tag:speech_v1_generated_Adaptation_UpdateCustomClass_async + */ updateCustomClass( - request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest | undefined, + {} | undefined, + ] + >; updateCustomClass( - request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.IUpdateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'custom_class.name': request.customClass!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.ICustomClass, + | protos.google.cloud.speech.v1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.ICustomClass, - protos.google.cloud.speech.v1.IUpdateCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.ICustomClass, + protos.google.cloud.speech.v1.IUpdateCustomClassRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Delete a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the custom class to delete. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/adaptation.delete_custom_class.js - * region_tag:speech_v1_generated_Adaptation_DeleteCustomClass_async - */ + /** + * Delete a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to delete. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/adaptation.delete_custom_class.js + * region_tag:speech_v1_generated_Adaptation_DeleteCustomClass_async + */ deleteCustomClass( - request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest | undefined, + {} | undefined, + ] + >; deleteCustomClass( - request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1.IDeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1.IDeleteCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1.IDeleteCustomClassRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * List phrase sets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1.PhraseSet|PhraseSet}. - * 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 `listPhraseSetAsync()` - * method described below for async iteration which you can stop as 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 phrase sets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1.PhraseSet|PhraseSet}. + * 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 `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSet( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet[], - protos.google.cloud.speech.v1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1.IListPhraseSetResponse - ]>; + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet[], + protos.google.cloud.speech.v1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1.IListPhraseSetResponse, + ] + >; listPhraseSet( - request: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): void; + request: protos.google.cloud.speech.v1.IListPhraseSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse | null | undefined, + protos.google.cloud.speech.v1.IPhraseSet + >, + ): void; listPhraseSet( - request: protos.google.cloud.speech.v1.IListPhraseSetRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): void; + request: protos.google.cloud.speech.v1.IListPhraseSetRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse | null | undefined, + protos.google.cloud.speech.v1.IPhraseSet + >, + ): void; listPhraseSet( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>): - Promise<[ - protos.google.cloud.speech.v1.IPhraseSet[], - protos.google.cloud.speech.v1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1.IListPhraseSetResponse - ]>|void { + | protos.google.cloud.speech.v1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1.IPhraseSet + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + protos.google.cloud.speech.v1.IListPhraseSetResponse | null | undefined, + protos.google.cloud.speech.v1.IPhraseSet + >, + ): Promise< + [ + protos.google.cloud.speech.v1.IPhraseSet[], + protos.google.cloud.speech.v1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1.IListPhraseSetResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v1.IListPhraseSetRequest, - protos.google.cloud.speech.v1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1.IPhraseSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1.IPhraseSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPhraseSet values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1286,234 +1650,263 @@ export class AdaptationClient { this._log.info('listPhraseSet request %j', request); return this.innerApiCalls .listPhraseSet(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v1.IPhraseSet[], - protos.google.cloud.speech.v1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1.IListPhraseSetResponse - ]) => { - this._log.info('listPhraseSet values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v1.IPhraseSet[], + protos.google.cloud.speech.v1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1.IListPhraseSetResponse, + ]) => { + this._log.info('listPhraseSet values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPhraseSet`, 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 phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1.PhraseSet|PhraseSet} 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 `listPhraseSetAsync()` - * method described below for async iteration which you can stop as 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 `listPhraseSet`, 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 phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1.PhraseSet|PhraseSet} 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 `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSetStream( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + 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['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSet stream %j', request); return this.descriptors.page.listPhraseSet.createStream( this.innerApiCalls.listPhraseSet as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPhraseSet`, 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 phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1.PhraseSet|PhraseSet}. 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/adaptation.list_phrase_set.js - * region_tag:speech_v1_generated_Adaptation_ListPhraseSet_async - */ + /** + * Equivalent to `listPhraseSet`, 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 phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1.PhraseSet|PhraseSet}. 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/adaptation.list_phrase_set.js + * region_tag:speech_v1_generated_Adaptation_ListPhraseSet_async + */ listPhraseSetAsync( - request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v1.IListPhraseSetRequest, + 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['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSet iterate %j', request); return this.descriptors.page.listPhraseSet.asyncIterate( this.innerApiCalls['listPhraseSet'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List custom classes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1.CustomClass|CustomClass}. - * 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 custom classes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1.CustomClass|CustomClass}. + * 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClasses( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass[], - protos.google.cloud.speech.v1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1.IListCustomClassesResponse - ]>; + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass[], + protos.google.cloud.speech.v1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1.IListCustomClassesResponse, + ] + >; listCustomClasses( - request: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): void; + request: protos.google.cloud.speech.v1.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1.ICustomClass + >, + ): void; listCustomClasses( - request: protos.google.cloud.speech.v1.IListCustomClassesRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): void; + request: protos.google.cloud.speech.v1.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1.ICustomClass + >, + ): void; listCustomClasses( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>, - callback?: PaginationCallback< + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>): - Promise<[ - protos.google.cloud.speech.v1.ICustomClass[], - protos.google.cloud.speech.v1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1.IListCustomClassesResponse - ]>|void { + | protos.google.cloud.speech.v1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1.ICustomClass + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1.ICustomClass + >, + ): Promise< + [ + protos.google.cloud.speech.v1.ICustomClass[], + protos.google.cloud.speech.v1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1.IListCustomClassesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v1.IListCustomClassesRequest, - protos.google.cloud.speech.v1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1.ICustomClass>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1.ICustomClass + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCustomClasses values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1522,136 +1915,140 @@ export class AdaptationClient { this._log.info('listCustomClasses request %j', request); return this.innerApiCalls .listCustomClasses(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v1.ICustomClass[], - protos.google.cloud.speech.v1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1.IListCustomClassesResponse - ]) => { - this._log.info('listCustomClasses values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v1.ICustomClass[], + protos.google.cloud.speech.v1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1.IListCustomClassesResponse, + ]) => { + this._log.info('listCustomClasses values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCustomClasses`, 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 custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1.CustomClass|CustomClass} 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 `listCustomClasses`, 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 custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1.CustomClass|CustomClass} 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClassesStream( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses stream %j', request); return this.descriptors.page.listCustomClasses.createStream( this.innerApiCalls.listCustomClasses as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCustomClasses`, 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 custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1.CustomClass|CustomClass}. 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/adaptation.list_custom_classes.js - * region_tag:speech_v1_generated_Adaptation_ListCustomClasses_async - */ + /** + * Equivalent to `listCustomClasses`, 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 custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1.CustomClass|CustomClass}. 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/adaptation.list_custom_classes.js + * region_tag:speech_v1_generated_Adaptation_ListCustomClasses_async + */ listCustomClassesAsync( - request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v1.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses iterate %j', request); return this.descriptors.page.listCustomClasses.asyncIterate( this.innerApiCalls['listCustomClasses'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1666,7 +2063,7 @@ export class AdaptationClient { * @param {string} custom_class * @returns {string} Resource name string. */ - customClassPath(project:string,location:string,customClass:string) { + customClassPath(project: string, location: string, customClass: string) { return this.pathTemplates.customClassPathTemplate.render({ project: project, location: location, @@ -1682,7 +2079,8 @@ export class AdaptationClient { * @returns {string} A string representing the project. */ matchProjectFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).project; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; } /** @@ -1693,7 +2091,8 @@ export class AdaptationClient { * @returns {string} A string representing the location. */ matchLocationFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).location; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; } /** @@ -1704,7 +2103,8 @@ export class AdaptationClient { * @returns {string} A string representing the custom_class. */ matchCustomClassFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; } /** @@ -1714,7 +2114,7 @@ export class AdaptationClient { * @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, @@ -1751,7 +2151,7 @@ export class AdaptationClient { * @param {string} phrase_set * @returns {string} Resource name string. */ - phraseSetPath(project:string,location:string,phraseSet:string) { + phraseSetPath(project: string, location: string, phraseSet: string) { return this.pathTemplates.phraseSetPathTemplate.render({ project: project, location: location, @@ -1767,7 +2167,8 @@ export class AdaptationClient { * @returns {string} A string representing the project. */ matchProjectFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).project; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; } /** @@ -1778,7 +2179,8 @@ export class AdaptationClient { * @returns {string} A string representing the location. */ matchLocationFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).location; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; } /** @@ -1789,7 +2191,8 @@ export class AdaptationClient { * @returns {string} A string representing the phrase_set. */ matchPhraseSetFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; } /** @@ -1798,7 +2201,7 @@ export class AdaptationClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1823,7 +2226,7 @@ export class AdaptationClient { */ close(): Promise { if (this.adaptationStub && !this._terminated) { - return this.adaptationStub.then(stub => { + return this.adaptationStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1831,4 +2234,4 @@ export class AdaptationClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-speech/src/v1/index.ts b/packages/google-cloud-speech/src/v1/index.ts index f638f480e0a0..6ccf0c8b2f19 100644 --- a/packages/google-cloud-speech/src/v1/index.ts +++ b/packages/google-cloud-speech/src/v1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {AdaptationClient} from './adaptation_client'; -export {SpeechClient} from './speech_client'; +export { AdaptationClient } from './adaptation_client'; +export { SpeechClient } from './speech_client'; diff --git a/packages/google-cloud-speech/src/v1/speech_client.ts b/packages/google-cloud-speech/src/v1/speech_client.ts index fb89ae46e984..f17f6e9e6253 100644 --- a/packages/google-cloud-speech/src/v1/speech_client.ts +++ b/packages/google-cloud-speech/src/v1/speech_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; -import {PassThrough} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, +} from 'google-gax'; +import { 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 +51,7 @@ export class SpeechClient { 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('speech'); @@ -57,10 +64,10 @@ export class SpeechClient { 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; - speechStub?: Promise<{[name: string]: Function}>; + speechStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SpeechClient. @@ -101,21 +108,42 @@ export class SpeechClient { * const client = new SpeechClient({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 SpeechClient; - 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 = 'speech.' + 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 +168,7 @@ export class SpeechClient { 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 +182,7 @@ export class SpeechClient { } // 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,17 +204,21 @@ export class SpeechClient { // Create useful helper objects for these. this.pathTemplates = { customClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/customClasses/{custom_class}' + 'projects/{project}/locations/{location}/customClasses/{custom_class}', ), phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}', ), }; // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { - streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries) + streamingRecognize: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + !!opts.gaxServerStreamingRetries, + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -198,29 +227,46 @@ export class SpeechClient { // 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.longrunning.Operations.GetOperation',get: '/v1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/operations/{name=**}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const longRunningRecognizeResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v1.LongRunningRecognizeResponse') as gax.protobuf.Type; + '.google.cloud.speech.v1.LongRunningRecognizeResponse', + ) as gax.protobuf.Type; const longRunningRecognizeMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v1.LongRunningRecognizeMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v1.LongRunningRecognizeMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { longRunningRecognize: new this._gaxModule.LongrunningDescriptor( this.operationsClient, longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), - longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) + longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1.Speech', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.speech.v1.Speech', + 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 @@ -251,35 +297,49 @@ export class SpeechClient { // Put together the "service stub" for // google.cloud.speech.v1.Speech. this.speechStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1.Speech') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v1.Speech', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.speech.v1.Speech, - 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 speechStubMethods = - ['recognize', 'longRunningRecognize', 'streamingRecognize']; + const speechStubMethods = [ + 'recognize', + 'longRunningRecognize', + 'streamingRecognize', + ]; for (const methodName of speechStubMethods) { const callPromise = this.speechStub.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.stream[methodName] || @@ -289,7 +349,7 @@ export class SpeechClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -304,8 +364,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -316,8 +382,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -348,9 +420,7 @@ export class SpeechClient { * @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; @@ -359,8 +429,9 @@ export class SpeechClient { * 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; @@ -371,236 +442,330 @@ export class SpeechClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Performs synchronous speech recognition: receive results after all audio - * has been sent and processed. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.RecognizeResponse|RecognizeResponse}. - * Please see the {@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/speech.recognize.js - * region_tag:speech_v1_generated_Speech_Recognize_async - */ + /** + * Performs synchronous speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1.RecognizeResponse|RecognizeResponse}. + * Please see the {@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/speech.recognize.js + * region_tag:speech_v1_generated_Speech_Recognize_async + */ recognize( - request?: protos.google.cloud.speech.v1.IRecognizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.IRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | undefined, + {} | undefined, + ] + >; recognize( - request: protos.google.cloud.speech.v1.IRecognizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request: protos.google.cloud.speech.v1.IRecognizeRequest, - callback: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request?: protos.google.cloud.speech.v1.IRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1.IRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('recognize request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('recognize response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.recognize(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1.IRecognizeResponse, - protos.google.cloud.speech.v1.IRecognizeRequest|undefined, - {}|undefined - ]) => { - this._log.info('recognize response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .recognize(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1.IRecognizeResponse, + protos.google.cloud.speech.v1.IRecognizeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('recognize response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @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.speech.v1.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and - * will emit objects representing {@link protos.google.cloud.speech.v1.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v1/speech.streaming_recognize.js - * region_tag:speech_v1_generated_Speech_StreamingRecognize_async - */ - _streamingRecognize( - options?: CallOptions): - gax.CancellableStream { - this.initialize().catch(err => {throw err}); + /** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @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.speech.v1.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.speech.v1.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v1/speech.streaming_recognize.js + * region_tag:speech_v1_generated_Speech_StreamingRecognize_async + */ + _streamingRecognize(options?: CallOptions): gax.CancellableStream { + this.initialize().catch((err) => { + throw err; + }); this._log.info('streamingRecognize stream %j', options); return this.innerApiCalls.streamingRecognize(null, options); } -/** - * Performs asynchronous speech recognition: receive results via the - * google.longrunning.Operations interface. Returns either an - * `Operation.error` or an `Operation.response` which contains - * a `LongRunningRecognizeResponse` message. - * For more information on asynchronous speech recognition, see the - * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig] - * Optional. Specifies an optional destination for the recognition 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/speech.long_running_recognize.js - * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async - */ + /** + * Performs asynchronous speech recognition: receive results via the + * google.longrunning.Operations interface. Returns either an + * `Operation.error` or an `Operation.response` which contains + * a `LongRunningRecognizeResponse` message. + * For more information on asynchronous speech recognition, see the + * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {google.cloud.speech.v1.TranscriptOutputConfig} [request.outputConfig] + * Optional. Specifies an optional destination for the recognition 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/speech.long_running_recognize.js + * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async + */ longRunningRecognize( - request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; longRunningRecognize( - request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; longRunningRecognize( - request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; longRunningRecognize( - request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v1.ILongRunningRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('longRunningRecognize response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('longRunningRecognize request %j', request); - return this.innerApiCalls.longRunningRecognize(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('longRunningRecognize response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .longRunningRecognize(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('longRunningRecognize response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `longRunningRecognize()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/speech.long_running_recognize.js - * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async - */ - async checkLongRunningRecognizeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `longRunningRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/speech.long_running_recognize.js + * region_tag:speech_v1_generated_Speech_LongRunningRecognize_async + */ + async checkLongRunningRecognizeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v1.LongRunningRecognizeResponse, + protos.google.cloud.speech.v1.LongRunningRecognizeMetadata + > + > { this._log.info('longRunningRecognize long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.longRunningRecognize, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v1.LongRunningRecognizeResponse, + protos.google.cloud.speech.v1.LongRunningRecognizeMetadata + >; } -/** + /** * 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. @@ -643,22 +808,22 @@ export class SpeechClient { 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); } /** @@ -693,15 +858,15 @@ export class SpeechClient { */ 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); } /** @@ -735,7 +900,7 @@ export class SpeechClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -748,25 +913,24 @@ export class SpeechClient { 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 @@ -805,22 +969,22 @@ export class SpeechClient { 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); } @@ -836,7 +1000,7 @@ export class SpeechClient { * @param {string} custom_class * @returns {string} Resource name string. */ - customClassPath(project:string,location:string,customClass:string) { + customClassPath(project: string, location: string, customClass: string) { return this.pathTemplates.customClassPathTemplate.render({ project: project, location: location, @@ -852,7 +1016,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).project; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; } /** @@ -863,7 +1028,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).location; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; } /** @@ -874,7 +1040,8 @@ export class SpeechClient { * @returns {string} A string representing the custom_class. */ matchCustomClassFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; } /** @@ -885,7 +1052,7 @@ export class SpeechClient { * @param {string} phrase_set * @returns {string} Resource name string. */ - phraseSetPath(project:string,location:string,phraseSet:string) { + phraseSetPath(project: string, location: string, phraseSet: string) { return this.pathTemplates.phraseSetPathTemplate.render({ project: project, location: location, @@ -901,7 +1068,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).project; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; } /** @@ -912,7 +1080,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).location; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; } /** @@ -923,7 +1092,8 @@ export class SpeechClient { * @returns {string} A string representing the phrase_set. */ matchPhraseSetFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; } /** @@ -934,7 +1104,7 @@ export class SpeechClient { */ close(): Promise { if (this.speechStub && !this._terminated) { - return this.speechStub.then(stub => { + return this.speechStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -944,6 +1114,7 @@ export class SpeechClient { return Promise.resolve(); } } + import {ImprovedStreamingClient} from '../helpers'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface SpeechClient extends ImprovedStreamingClient {} diff --git a/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts b/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts index 40e8cb15ef8a..fbc7b12304a4 100644 --- a/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts +++ b/packages/google-cloud-speech/src/v1p1beta1/adaptation_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class AdaptationClient { 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('speech'); @@ -57,9 +64,9 @@ export class AdaptationClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - adaptationStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + adaptationStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of AdaptationClient. @@ -100,21 +107,42 @@ export class AdaptationClient { * const client = new AdaptationClient({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 AdaptationClient; - 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 = 'speech.' + 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; @@ -139,7 +167,7 @@ export class AdaptationClient { 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; @@ -153,10 +181,7 @@ export class AdaptationClient { } // 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 { @@ -178,16 +203,16 @@ export class AdaptationClient { // Create useful helper objects for these. this.pathTemplates = { customClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/customClasses/{custom_class}' + 'projects/{project}/locations/{location}/customClasses/{custom_class}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -195,16 +220,25 @@ export class AdaptationClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listPhraseSet: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'phraseSets'), - listCustomClasses: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customClasses') + listPhraseSet: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'phraseSets', + ), + listCustomClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'customClasses', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1p1beta1.Adaptation', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.speech.v1p1beta1.Adaptation', + 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 @@ -235,37 +269,51 @@ export class AdaptationClient { // Put together the "service stub" for // google.cloud.speech.v1p1beta1.Adaptation. this.adaptationStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Adaptation') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v1p1beta1.Adaptation', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.speech.v1p1beta1.Adaptation, - 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 adaptationStubMethods = - ['createPhraseSet', 'getPhraseSet', 'listPhraseSet', 'updatePhraseSet', 'deletePhraseSet', 'createCustomClass', 'getCustomClass', 'listCustomClasses', 'updateCustomClass', 'deleteCustomClass']; + const adaptationStubMethods = [ + 'createPhraseSet', + 'getPhraseSet', + 'listPhraseSet', + 'updatePhraseSet', + 'deletePhraseSet', + 'createCustomClass', + 'getCustomClass', + 'listCustomClasses', + 'updateCustomClass', + 'deleteCustomClass', + ]; for (const methodName of adaptationStubMethods) { const callPromise = this.adaptationStub.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; @@ -280,8 +328,14 @@ export class AdaptationClient { * @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 'speech.googleapis.com'; } @@ -292,8 +346,14 @@ export class AdaptationClient { * @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 'speech.googleapis.com'; } @@ -324,9 +384,7 @@ export class AdaptationClient { * @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; @@ -335,8 +393,9 @@ export class AdaptationClient { * 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; @@ -347,937 +406,1321 @@ export class AdaptationClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Create a set of phrase hints. Each item in the set can be a single word or - * a multi-word phrase. The items in the PhraseSet are favored by the - * recognition model when you send a call that includes the PhraseSet. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this phrase set will be created. - * Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.phraseSetId - * Required. The ID to use for the phrase set, which will become the final - * component of the phrase set's resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet - * Required. The phrase set to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.create_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async - */ + /** + * Create a set of phrase hints. Each item in the set can be a single word or + * a multi-word phrase. The items in the PhraseSet are favored by the + * recognition model when you send a call that includes the PhraseSet. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this phrase set will be created. + * Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.phraseSetId + * Required. The ID to use for the phrase set, which will become the final + * component of the phrase set's resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet + * Required. The phrase set to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.create_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_CreatePhraseSet_async + */ createPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest | undefined, + {} | undefined, + ] + >; createPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createPhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createPhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createPhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('createPhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + ( + | protos.google.cloud.speech.v1p1beta1.ICreatePhraseSetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createPhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the phrase set to retrieve. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.get_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async - */ + /** + * Get a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to retrieve. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.get_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_GetPhraseSet_async + */ getPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + >; getPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getPhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IGetPhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet - * Required. The phrase set to update. - * - * The phrase set's `name` field is used to identify the set to be - * updated. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields 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 {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.update_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async - */ + /** + * Update a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.PhraseSet} request.phraseSet + * Required. The phrase set to update. + * + * The phrase set's `name` field is used to identify the set to be + * updated. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields 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 {@link protos.google.cloud.speech.v1p1beta1.PhraseSet|PhraseSet}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.update_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_UpdatePhraseSet_async + */ updatePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest | undefined, + {} | undefined, + ] + >; updatePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'phrase_set.name': request.phraseSet!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updatePhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updatePhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updatePhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.IPhraseSet, - protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('updatePhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updatePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdatePhraseSetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updatePhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Delete a phrase set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the phrase set to delete. Format: - * - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1p1beta1/adaptation.delete_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async - */ + /** + * Delete a phrase set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the phrase set to delete. Format: + * + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1p1beta1/adaptation.delete_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_DeletePhraseSet_async + */ deletePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest | undefined, + {} | undefined, + ] + >; deletePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deletePhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deletePhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deletePhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('deletePhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deletePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeletePhraseSetRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deletePhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Create a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this custom class will be created. - * Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {string} request.customClassId - * Required. The ID to use for the custom class, which will become the final - * component of the custom class' resource name. - * - * This value should restrict to letters, numbers, and hyphens, with the first - * character a letter, the last a letter or a number, and be 4-63 characters. - * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass - * Required. The custom class to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.create_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async - */ + /** + * Create a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this custom class will be created. + * Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {string} request.customClassId + * Required. The ID to use for the custom class, which will become the final + * component of the custom class' resource name. + * + * This value should restrict to letters, numbers, and hyphens, with the first + * character a letter, the last a letter or a number, and be 4-63 characters. + * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass + * Required. The custom class to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.create_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_CreateCustomClass_async + */ createCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | undefined + ), + {} | undefined, + ] + >; createCustomClass( - request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.ICreateCustomClassRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the custom class to retrieve. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.get_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_GetCustomClass_async - */ + /** + * Get a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to retrieve. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.get_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_GetCustomClass_async + */ getCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest | undefined, + {} | undefined, + ] + >; getCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IGetCustomClassRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass - * Required. The custom class to update. - * - * The custom class's `name` field is used to identify the custom class to be - * updated. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields 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 {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/adaptation.update_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async - */ + /** + * Update a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.CustomClass} request.customClass + * Required. The custom class to update. + * + * The custom class's `name` field is used to identify the custom class to be + * updated. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields 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 {@link protos.google.cloud.speech.v1p1beta1.CustomClass|CustomClass}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/adaptation.update_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_UpdateCustomClass_async + */ updateCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | undefined + ), + {} | undefined, + ] + >; updateCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'custom_class.name': request.customClass!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.ICustomClass, + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.ICustomClass, - protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.ICustomClass, + ( + | protos.google.cloud.speech.v1p1beta1.IUpdateCustomClassRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Delete a custom class. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the custom class to delete. Format: - * - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1p1beta1/adaptation.delete_custom_class.js - * region_tag:speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async - */ + /** + * Delete a custom class. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the custom class to delete. Format: + * + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v1p1beta1/adaptation.delete_custom_class.js + * region_tag:speech_v1p1beta1_generated_Adaptation_DeleteCustomClass_async + */ deleteCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | undefined + ), + {} | undefined, + ] + >; deleteCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.speech.v1p1beta1.IDeleteCustomClassRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * List phrase sets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet}. - * 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 `listPhraseSetAsync()` - * method described below for async iteration which you can stop as 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 phrase sets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet}. + * 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 `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet[], - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse, + ] + >; listPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + >, + ): void; listPhraseSet( - request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): void; + request: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + >, + ): void; listPhraseSet( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IPhraseSet[], - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v1p1beta1.IListPhraseSetRequest, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.IPhraseSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + | protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.IPhraseSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPhraseSet values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1286,234 +1729,263 @@ export class AdaptationClient { this._log.info('listPhraseSet request %j', request); return this.innerApiCalls .listPhraseSet(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v1p1beta1.IPhraseSet[], - protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest|null, - protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse - ]) => { - this._log.info('listPhraseSet values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v1p1beta1.IPhraseSet[], + protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest | null, + protos.google.cloud.speech.v1p1beta1.IListPhraseSetResponse, + ]) => { + this._log.info('listPhraseSet values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPhraseSet`, 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 phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet} 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 `listPhraseSetAsync()` - * method described below for async iteration which you can stop as 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 `listPhraseSet`, 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 phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet} 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 `listPhraseSetAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSetStream( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + 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['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSet stream %j', request); return this.descriptors.page.listPhraseSet.createStream( this.innerApiCalls.listPhraseSet as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPhraseSet`, 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 phrase set. Format: - * - * `projects/{project}/locations/{location}` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of phrase sets to return. The service may return - * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListPhraseSet` must - * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet}. 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/v1p1beta1/adaptation.list_phrase_set.js - * region_tag:speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async - */ + /** + * Equivalent to `listPhraseSet`, 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 phrase set. Format: + * + * `projects/{project}/locations/{location}` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of phrase sets to return. The service may return + * fewer than this value. If unspecified, at most 50 phrase sets 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 `ListPhraseSet` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListPhraseSet` must + * match the call that provided 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.speech.v1p1beta1.PhraseSet|PhraseSet}. 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/v1p1beta1/adaptation.list_phrase_set.js + * region_tag:speech_v1p1beta1_generated_Adaptation_ListPhraseSet_async + */ listPhraseSetAsync( - request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v1p1beta1.IListPhraseSetRequest, + 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['listPhraseSet']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSet iterate %j', request); return this.descriptors.page.listPhraseSet.asyncIterate( this.innerApiCalls['listPhraseSet'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * List custom classes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent, which owns this collection of custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass}. - * 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 custom classes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent, which owns this collection of custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass}. + * 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClasses( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass[], - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse, + ] + >; listCustomClasses( - request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + >, + ): void; listCustomClasses( - request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): void; + request: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + >, + ): void; listCustomClasses( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>, - callback?: PaginationCallback< - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.ICustomClass[], - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v1p1beta1.IListCustomClassesRequest, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v1p1beta1.ICustomClass>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + | protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v1p1beta1.ICustomClass + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCustomClasses values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1522,136 +1994,140 @@ export class AdaptationClient { this._log.info('listCustomClasses request %j', request); return this.innerApiCalls .listCustomClasses(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v1p1beta1.ICustomClass[], - protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest|null, - protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse - ]) => { - this._log.info('listCustomClasses values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v1p1beta1.ICustomClass[], + protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest | null, + protos.google.cloud.speech.v1p1beta1.IListCustomClassesResponse, + ]) => { + this._log.info('listCustomClasses values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCustomClasses`, 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 custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass} 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 `listCustomClasses`, 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 custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass} 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClassesStream( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses stream %j', request); return this.descriptors.page.listCustomClasses.createStream( this.innerApiCalls.listCustomClasses as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCustomClasses`, 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 custom classes. Format: - * - * `projects/{project}/locations/{location}/customClasses` - * - * Speech-to-Text supports three locations: `global`, `us` (US North America), - * and `eu` (Europe). If you are calling the `speech.googleapis.com` - * endpoint, use the `global` location. To specify a region, use a - * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) - * with matching `us` or `eu` location value. - * @param {number} request.pageSize - * The maximum number of custom classes to return. The service may return - * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListCustomClass` must - * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass}. 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/v1p1beta1/adaptation.list_custom_classes.js - * region_tag:speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async - */ + /** + * Equivalent to `listCustomClasses`, 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 custom classes. Format: + * + * `projects/{project}/locations/{location}/customClasses` + * + * Speech-to-Text supports three locations: `global`, `us` (US North America), + * and `eu` (Europe). If you are calling the `speech.googleapis.com` + * endpoint, use the `global` location. To specify a region, use a + * [regional endpoint](https://cloud.google.com/speech-to-text/docs/endpoints) + * with matching `us` or `eu` location value. + * @param {number} request.pageSize + * The maximum number of custom classes to return. The service may return + * fewer than this value. If unspecified, at most 50 custom classes 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 `ListCustomClass` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListCustomClass` must + * match the call that provided 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.speech.v1p1beta1.CustomClass|CustomClass}. 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/v1p1beta1/adaptation.list_custom_classes.js + * region_tag:speech_v1p1beta1_generated_Adaptation_ListCustomClasses_async + */ listCustomClassesAsync( - request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v1p1beta1.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses iterate %j', request); return this.descriptors.page.listCustomClasses.asyncIterate( this.innerApiCalls['listCustomClasses'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1666,7 +2142,7 @@ export class AdaptationClient { * @param {string} custom_class * @returns {string} Resource name string. */ - customClassPath(project:string,location:string,customClass:string) { + customClassPath(project: string, location: string, customClass: string) { return this.pathTemplates.customClassPathTemplate.render({ project: project, location: location, @@ -1682,7 +2158,8 @@ export class AdaptationClient { * @returns {string} A string representing the project. */ matchProjectFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).project; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; } /** @@ -1693,7 +2170,8 @@ export class AdaptationClient { * @returns {string} A string representing the location. */ matchLocationFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).location; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; } /** @@ -1704,7 +2182,8 @@ export class AdaptationClient { * @returns {string} A string representing the custom_class. */ matchCustomClassFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; } /** @@ -1714,7 +2193,7 @@ export class AdaptationClient { * @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, @@ -1751,7 +2230,7 @@ export class AdaptationClient { * @param {string} phrase_set * @returns {string} Resource name string. */ - phraseSetPath(project:string,location:string,phraseSet:string) { + phraseSetPath(project: string, location: string, phraseSet: string) { return this.pathTemplates.phraseSetPathTemplate.render({ project: project, location: location, @@ -1767,7 +2246,8 @@ export class AdaptationClient { * @returns {string} A string representing the project. */ matchProjectFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).project; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; } /** @@ -1778,7 +2258,8 @@ export class AdaptationClient { * @returns {string} A string representing the location. */ matchLocationFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).location; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; } /** @@ -1789,7 +2270,8 @@ export class AdaptationClient { * @returns {string} A string representing the phrase_set. */ matchPhraseSetFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; } /** @@ -1798,7 +2280,7 @@ export class AdaptationClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1823,7 +2305,7 @@ export class AdaptationClient { */ close(): Promise { if (this.adaptationStub && !this._terminated) { - return this.adaptationStub.then(stub => { + return this.adaptationStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1831,4 +2313,4 @@ export class AdaptationClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-speech/src/v1p1beta1/index.ts b/packages/google-cloud-speech/src/v1p1beta1/index.ts index f638f480e0a0..6ccf0c8b2f19 100644 --- a/packages/google-cloud-speech/src/v1p1beta1/index.ts +++ b/packages/google-cloud-speech/src/v1p1beta1/index.ts @@ -16,5 +16,5 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {AdaptationClient} from './adaptation_client'; -export {SpeechClient} from './speech_client'; +export { AdaptationClient } from './adaptation_client'; +export { SpeechClient } from './speech_client'; diff --git a/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts b/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts index c4d7d58495d4..7573726dc0b0 100644 --- a/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts +++ b/packages/google-cloud-speech/src/v1p1beta1/speech_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation} from 'google-gax'; -import {PassThrough} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, +} from 'google-gax'; +import { 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 +51,7 @@ export class SpeechClient { 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('speech'); @@ -57,10 +64,10 @@ export class SpeechClient { 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; - speechStub?: Promise<{[name: string]: Function}>; + speechStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SpeechClient. @@ -101,21 +108,42 @@ export class SpeechClient { * const client = new SpeechClient({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 SpeechClient; - 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 = 'speech.' + 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 +168,7 @@ export class SpeechClient { 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 +182,7 @@ export class SpeechClient { } // 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,17 +204,21 @@ export class SpeechClient { // Create useful helper objects for these. this.pathTemplates = { customClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/customClasses/{custom_class}' + 'projects/{project}/locations/{location}/customClasses/{custom_class}', ), phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}', ), }; // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { - streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries) + streamingRecognize: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + !!opts.gaxServerStreamingRetries, + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -198,29 +227,46 @@ export class SpeechClient { // 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.longrunning.Operations.GetOperation',get: '/v1p1beta1/operations/{name=**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v1p1beta1/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1p1beta1/operations/{name=**}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1p1beta1/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const longRunningRecognizeResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse') as gax.protobuf.Type; + '.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse', + ) as gax.protobuf.Type; const longRunningRecognizeMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { longRunningRecognize: new this._gaxModule.LongrunningDescriptor( this.operationsClient, longRunningRecognizeResponse.decode.bind(longRunningRecognizeResponse), - longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata)) + longRunningRecognizeMetadata.decode.bind(longRunningRecognizeMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v1p1beta1.Speech', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.speech.v1p1beta1.Speech', + 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 @@ -251,35 +297,49 @@ export class SpeechClient { // Put together the "service stub" for // google.cloud.speech.v1p1beta1.Speech. this.speechStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v1p1beta1.Speech') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v1p1beta1.Speech', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.speech.v1p1beta1.Speech, - 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 speechStubMethods = - ['recognize', 'longRunningRecognize', 'streamingRecognize']; + const speechStubMethods = [ + 'recognize', + 'longRunningRecognize', + 'streamingRecognize', + ]; for (const methodName of speechStubMethods) { const callPromise = this.speechStub.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.stream[methodName] || @@ -289,7 +349,7 @@ export class SpeechClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -304,8 +364,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -316,8 +382,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -348,9 +420,7 @@ export class SpeechClient { * @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; @@ -359,8 +429,9 @@ export class SpeechClient { * 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; @@ -371,236 +442,334 @@ export class SpeechClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Performs synchronous speech recognition: receive results after all audio - * has been sent and processed. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.RecognizeResponse|RecognizeResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_Recognize_async - */ + /** + * Performs synchronous speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v1p1beta1.RecognizeResponse|RecognizeResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_Recognize_async + */ recognize( - request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | undefined, + {} | undefined, + ] + >; recognize( - request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - callback: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v1p1beta1.IRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v1p1beta1.IRecognizeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('recognize request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + | protos.google.cloud.speech.v1p1beta1.IRecognizeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('recognize response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.recognize(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, - protos.google.cloud.speech.v1p1beta1.IRecognizeRequest|undefined, - {}|undefined - ]) => { - this._log.info('recognize response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .recognize(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v1p1beta1.IRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.IRecognizeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('recognize response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @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.speech.v1p1beta1.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and - * will emit objects representing {@link protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v1p1beta1/speech.streaming_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_StreamingRecognize_async - */ - _streamingRecognize( - options?: CallOptions): - gax.CancellableStream { - this.initialize().catch(err => {throw err}); + /** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @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.speech.v1p1beta1.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v1p1beta1/speech.streaming_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_StreamingRecognize_async + */ + _streamingRecognize(options?: CallOptions): gax.CancellableStream { + this.initialize().catch((err) => { + throw err; + }); this._log.info('streamingRecognize stream %j', options); return this.innerApiCalls.streamingRecognize(null, options); } -/** - * Performs asynchronous speech recognition: receive results via the - * google.longrunning.Operations interface. Returns either an - * `Operation.error` or an `Operation.response` which contains - * a `LongRunningRecognizeResponse` message. - * For more information on asynchronous speech recognition, see the - * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config - * Required. Provides information to the recognizer that specifies how to - * process the request. - * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio - * Required. The audio data to be recognized. - * @param {google.cloud.speech.v1p1beta1.TranscriptOutputConfig} [request.outputConfig] - * Optional. Specifies an optional destination for the recognition 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async - */ + /** + * Performs asynchronous speech recognition: receive results via the + * google.longrunning.Operations interface. Returns either an + * `Operation.error` or an `Operation.response` which contains + * a `LongRunningRecognizeResponse` message. + * For more information on asynchronous speech recognition, see the + * [how-to](https://cloud.google.com/speech-to-text/docs/async-recognize). + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v1p1beta1.RecognitionConfig} request.config + * Required. Provides information to the recognizer that specifies how to + * process the request. + * @param {google.cloud.speech.v1p1beta1.RecognitionAudio} request.audio + * Required. The audio data to be recognized. + * @param {google.cloud.speech.v1p1beta1.TranscriptOutputConfig} [request.outputConfig] + * Optional. Specifies an optional destination for the recognition 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async + */ longRunningRecognize( - request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; longRunningRecognize( - request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; longRunningRecognize( - request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; longRunningRecognize( - request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('longRunningRecognize response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('longRunningRecognize request %j', request); - return this.innerApiCalls.longRunningRecognize(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('longRunningRecognize response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .longRunningRecognize(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('longRunningRecognize response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `longRunningRecognize()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js - * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async - */ - async checkLongRunningRecognizeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `longRunningRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1p1beta1/speech.long_running_recognize.js + * region_tag:speech_v1p1beta1_generated_Speech_LongRunningRecognize_async + */ + async checkLongRunningRecognizeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata + > + > { this._log.info('longRunningRecognize long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.longRunningRecognize, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.longRunningRecognize, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeMetadata + >; } -/** + /** * 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. @@ -643,22 +812,22 @@ export class SpeechClient { 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); } /** @@ -693,15 +862,15 @@ export class SpeechClient { */ 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); } /** @@ -735,7 +904,7 @@ export class SpeechClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -748,25 +917,24 @@ export class SpeechClient { 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 @@ -805,22 +973,22 @@ export class SpeechClient { 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); } @@ -836,7 +1004,7 @@ export class SpeechClient { * @param {string} custom_class * @returns {string} Resource name string. */ - customClassPath(project:string,location:string,customClass:string) { + customClassPath(project: string, location: string, customClass: string) { return this.pathTemplates.customClassPathTemplate.render({ project: project, location: location, @@ -852,7 +1020,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).project; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; } /** @@ -863,7 +1032,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).location; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; } /** @@ -874,7 +1044,8 @@ export class SpeechClient { * @returns {string} A string representing the custom_class. */ matchCustomClassFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; } /** @@ -885,7 +1056,7 @@ export class SpeechClient { * @param {string} phrase_set * @returns {string} Resource name string. */ - phraseSetPath(project:string,location:string,phraseSet:string) { + phraseSetPath(project: string, location: string, phraseSet: string) { return this.pathTemplates.phraseSetPathTemplate.render({ project: project, location: location, @@ -901,7 +1072,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).project; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; } /** @@ -912,7 +1084,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).location; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; } /** @@ -923,7 +1096,8 @@ export class SpeechClient { * @returns {string} A string representing the phrase_set. */ matchPhraseSetFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; } /** @@ -934,7 +1108,7 @@ export class SpeechClient { */ close(): Promise { if (this.speechStub && !this._terminated) { - return this.speechStub.then(stub => { + return this.speechStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -944,6 +1118,7 @@ export class SpeechClient { return Promise.resolve(); } } + import {ImprovedStreamingClient} from '../helpers'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface SpeechClient extends ImprovedStreamingClient {} diff --git a/packages/google-cloud-speech/src/v2/index.ts b/packages/google-cloud-speech/src/v2/index.ts index f6214bd82c8a..cfa376a32102 100644 --- a/packages/google-cloud-speech/src/v2/index.ts +++ b/packages/google-cloud-speech/src/v2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {SpeechClient} from './speech_client'; +export { SpeechClient } from './speech_client'; diff --git a/packages/google-cloud-speech/src/v2/speech_client.ts b/packages/google-cloud-speech/src/v2/speech_client.ts index e34f3f36ce07..ef2b559f69b8 100644 --- a/packages/google-cloud-speech/src/v2/speech_client.ts +++ b/packages/google-cloud-speech/src/v2/speech_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, PassThrough} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + 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 +55,7 @@ export class SpeechClient { 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('speech'); @@ -57,11 +68,11 @@ export class SpeechClient { 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; - speechStub?: Promise<{[name: string]: Function}>; + speechStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SpeechClient. @@ -102,21 +113,42 @@ export class SpeechClient { * const client = new SpeechClient({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 SpeechClient; - 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 = 'speech.' + 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 SpeechClient { 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 SpeechClient { } 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,28 +213,28 @@ export class SpeechClient { // Create useful helper objects for these. this.pathTemplates = { configPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/config' + 'projects/{project}/locations/{location}/config', ), 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}', ), customClassPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/customClasses/{custom_class}' + 'projects/{project}/locations/{location}/customClasses/{custom_class}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), phraseSetPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/phraseSets/{phrase_set}' + 'projects/{project}/locations/{location}/phraseSets/{phrase_set}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), recognizerPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/recognizers/{recognizer}' + 'projects/{project}/locations/{location}/recognizers/{recognizer}', ), }; @@ -214,18 +242,31 @@ export class SpeechClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listRecognizers: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'recognizers'), - listCustomClasses: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'customClasses'), - listPhraseSets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'phraseSets') + listRecognizers: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'recognizers', + ), + listCustomClasses: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'customClasses', + ), + listPhraseSets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'phraseSets', + ), }; // Some of the methods on this service provide streaming responses. // Provide descriptors for these. this.descriptors.stream = { - streamingRecognize: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, !!opts.fallback, !!opts.gaxServerStreamingRetries) + streamingRecognize: new this._gaxModule.StreamDescriptor( + this._gaxModule.StreamType.BIDI_STREAMING, + !!opts.fallback, + !!opts.gaxServerStreamingRetries, + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -234,125 +275,195 @@ export class SpeechClient { // 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.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.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 createRecognizerResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.Recognizer') as gax.protobuf.Type; + '.google.cloud.speech.v2.Recognizer', + ) as gax.protobuf.Type; const createRecognizerMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const updateRecognizerResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.Recognizer') as gax.protobuf.Type; + '.google.cloud.speech.v2.Recognizer', + ) as gax.protobuf.Type; const updateRecognizerMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const deleteRecognizerResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.Recognizer') as gax.protobuf.Type; + '.google.cloud.speech.v2.Recognizer', + ) as gax.protobuf.Type; const deleteRecognizerMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const undeleteRecognizerResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.Recognizer') as gax.protobuf.Type; + '.google.cloud.speech.v2.Recognizer', + ) as gax.protobuf.Type; const undeleteRecognizerMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const batchRecognizeResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.BatchRecognizeResponse') as gax.protobuf.Type; + '.google.cloud.speech.v2.BatchRecognizeResponse', + ) as gax.protobuf.Type; const batchRecognizeMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const createCustomClassResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.CustomClass') as gax.protobuf.Type; + '.google.cloud.speech.v2.CustomClass', + ) as gax.protobuf.Type; const createCustomClassMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const updateCustomClassResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.CustomClass') as gax.protobuf.Type; + '.google.cloud.speech.v2.CustomClass', + ) as gax.protobuf.Type; const updateCustomClassMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const deleteCustomClassResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.CustomClass') as gax.protobuf.Type; + '.google.cloud.speech.v2.CustomClass', + ) as gax.protobuf.Type; const deleteCustomClassMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const undeleteCustomClassResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.CustomClass') as gax.protobuf.Type; + '.google.cloud.speech.v2.CustomClass', + ) as gax.protobuf.Type; const undeleteCustomClassMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const createPhraseSetResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.PhraseSet') as gax.protobuf.Type; + '.google.cloud.speech.v2.PhraseSet', + ) as gax.protobuf.Type; const createPhraseSetMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const updatePhraseSetResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.PhraseSet') as gax.protobuf.Type; + '.google.cloud.speech.v2.PhraseSet', + ) as gax.protobuf.Type; const updatePhraseSetMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const deletePhraseSetResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.PhraseSet') as gax.protobuf.Type; + '.google.cloud.speech.v2.PhraseSet', + ) as gax.protobuf.Type; const deletePhraseSetMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; const undeletePhraseSetResponse = protoFilesRoot.lookup( - '.google.cloud.speech.v2.PhraseSet') as gax.protobuf.Type; + '.google.cloud.speech.v2.PhraseSet', + ) as gax.protobuf.Type; const undeletePhraseSetMetadata = protoFilesRoot.lookup( - '.google.cloud.speech.v2.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.speech.v2.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createRecognizer: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createRecognizerResponse.decode.bind(createRecognizerResponse), - createRecognizerMetadata.decode.bind(createRecognizerMetadata)), + createRecognizerMetadata.decode.bind(createRecognizerMetadata), + ), updateRecognizer: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateRecognizerResponse.decode.bind(updateRecognizerResponse), - updateRecognizerMetadata.decode.bind(updateRecognizerMetadata)), + updateRecognizerMetadata.decode.bind(updateRecognizerMetadata), + ), deleteRecognizer: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteRecognizerResponse.decode.bind(deleteRecognizerResponse), - deleteRecognizerMetadata.decode.bind(deleteRecognizerMetadata)), + deleteRecognizerMetadata.decode.bind(deleteRecognizerMetadata), + ), undeleteRecognizer: new this._gaxModule.LongrunningDescriptor( this.operationsClient, undeleteRecognizerResponse.decode.bind(undeleteRecognizerResponse), - undeleteRecognizerMetadata.decode.bind(undeleteRecognizerMetadata)), + undeleteRecognizerMetadata.decode.bind(undeleteRecognizerMetadata), + ), batchRecognize: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchRecognizeResponse.decode.bind(batchRecognizeResponse), - batchRecognizeMetadata.decode.bind(batchRecognizeMetadata)), + batchRecognizeMetadata.decode.bind(batchRecognizeMetadata), + ), createCustomClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createCustomClassResponse.decode.bind(createCustomClassResponse), - createCustomClassMetadata.decode.bind(createCustomClassMetadata)), + createCustomClassMetadata.decode.bind(createCustomClassMetadata), + ), updateCustomClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateCustomClassResponse.decode.bind(updateCustomClassResponse), - updateCustomClassMetadata.decode.bind(updateCustomClassMetadata)), + updateCustomClassMetadata.decode.bind(updateCustomClassMetadata), + ), deleteCustomClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteCustomClassResponse.decode.bind(deleteCustomClassResponse), - deleteCustomClassMetadata.decode.bind(deleteCustomClassMetadata)), + deleteCustomClassMetadata.decode.bind(deleteCustomClassMetadata), + ), undeleteCustomClass: new this._gaxModule.LongrunningDescriptor( this.operationsClient, undeleteCustomClassResponse.decode.bind(undeleteCustomClassResponse), - undeleteCustomClassMetadata.decode.bind(undeleteCustomClassMetadata)), + undeleteCustomClassMetadata.decode.bind(undeleteCustomClassMetadata), + ), createPhraseSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createPhraseSetResponse.decode.bind(createPhraseSetResponse), - createPhraseSetMetadata.decode.bind(createPhraseSetMetadata)), + createPhraseSetMetadata.decode.bind(createPhraseSetMetadata), + ), updatePhraseSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updatePhraseSetResponse.decode.bind(updatePhraseSetResponse), - updatePhraseSetMetadata.decode.bind(updatePhraseSetMetadata)), + updatePhraseSetMetadata.decode.bind(updatePhraseSetMetadata), + ), deletePhraseSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deletePhraseSetResponse.decode.bind(deletePhraseSetResponse), - deletePhraseSetMetadata.decode.bind(deletePhraseSetMetadata)), + deletePhraseSetMetadata.decode.bind(deletePhraseSetMetadata), + ), undeletePhraseSet: new this._gaxModule.LongrunningDescriptor( this.operationsClient, undeletePhraseSetResponse.decode.bind(undeletePhraseSetResponse), - undeletePhraseSetMetadata.decode.bind(undeletePhraseSetMetadata)) + undeletePhraseSetMetadata.decode.bind(undeletePhraseSetMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.speech.v2.Speech', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.speech.v2.Speech', + 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 @@ -383,35 +494,69 @@ export class SpeechClient { // Put together the "service stub" for // google.cloud.speech.v2.Speech. this.speechStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.speech.v2.Speech') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.speech.v2.Speech', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.speech.v2.Speech, - 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 speechStubMethods = - ['createRecognizer', 'listRecognizers', 'getRecognizer', 'updateRecognizer', 'deleteRecognizer', 'undeleteRecognizer', 'recognize', 'streamingRecognize', 'batchRecognize', 'getConfig', 'updateConfig', 'createCustomClass', 'listCustomClasses', 'getCustomClass', 'updateCustomClass', 'deleteCustomClass', 'undeleteCustomClass', 'createPhraseSet', 'listPhraseSets', 'getPhraseSet', 'updatePhraseSet', 'deletePhraseSet', 'undeletePhraseSet']; + const speechStubMethods = [ + 'createRecognizer', + 'listRecognizers', + 'getRecognizer', + 'updateRecognizer', + 'deleteRecognizer', + 'undeleteRecognizer', + 'recognize', + 'streamingRecognize', + 'batchRecognize', + 'getConfig', + 'updateConfig', + 'createCustomClass', + 'listCustomClasses', + 'getCustomClass', + 'updateCustomClass', + 'deleteCustomClass', + 'undeleteCustomClass', + 'createPhraseSet', + 'listPhraseSets', + 'getPhraseSet', + 'updatePhraseSet', + 'deletePhraseSet', + 'undeletePhraseSet', + ]; for (const methodName of speechStubMethods) { const callPromise = this.speechStub.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] || @@ -422,7 +567,7 @@ export class SpeechClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -437,8 +582,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -449,8 +600,14 @@ export class SpeechClient { * @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 'speech.googleapis.com'; } @@ -481,9 +638,7 @@ export class SpeechClient { * @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 +647,9 @@ export class SpeechClient { * 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,2287 +660,3300 @@ export class SpeechClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Returns the requested - * {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. Fails with - * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} if the requested Recognizer doesn't - * exist. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Recognizer to retrieve. The expected format is - * `projects/{project}/locations/{location}/recognizers/{recognizer}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * Please see the {@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/speech.get_recognizer.js - * region_tag:speech_v2_generated_Speech_GetRecognizer_async - */ + /** + * Returns the requested + * {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. Fails with + * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} if the requested Recognizer doesn't + * exist. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to retrieve. The expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * Please see the {@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/speech.get_recognizer.js + * region_tag:speech_v2_generated_Speech_GetRecognizer_async + */ getRecognizer( - request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | undefined, + {} | undefined, + ] + >; getRecognizer( - request: protos.google.cloud.speech.v2.IGetRecognizerRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetRecognizerRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + >, + ): void; getRecognizer( - request: protos.google.cloud.speech.v2.IGetRecognizerRequest, - callback: Callback< - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetRecognizerRequest, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + >, + ): void; getRecognizer( - request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IGetRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v2.IGetRecognizerRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getRecognizer request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.IRecognizer, + | protos.google.cloud.speech.v2.IGetRecognizerRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getRecognizer response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getRecognizer(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.IRecognizer, - protos.google.cloud.speech.v2.IGetRecognizerRequest|undefined, - {}|undefined - ]) => { - this._log.info('getRecognizer response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getRecognizer(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IGetRecognizerRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getRecognizer response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Performs synchronous Speech recognition: receive results after all audio - * has been sent and processed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.recognizer - * Required. The name of the Recognizer to use during recognition. The - * expected format is - * `projects/{project}/locations/{location}/recognizers/{recognizer}`. The - * {recognizer} segment may be set to `_` to use an empty implicit Recognizer. - * @param {google.cloud.speech.v2.RecognitionConfig} request.config - * Features and audio metadata to use for the Automatic Speech Recognition. - * This field in combination with the - * {@link protos.google.cloud.speech.v2.RecognizeRequest.config_mask|config_mask} field - * can be used to override parts of the - * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} - * of the Recognizer resource. - * @param {google.protobuf.FieldMask} request.configMask - * The list of fields in - * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} that override the - * values in the - * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} - * of the recognizer during this recognition request. If no mask is provided, - * all non-default valued fields in - * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} override the - * values in the recognizer for this recognition request. If a mask is - * provided, only the fields listed in the mask override the config in the - * recognizer for this recognition request. If a wildcard (`*`) is provided, - * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} completely - * overrides and replaces the config in the recognizer for this recognition - * request. - * @param {Buffer} request.content - * The audio data bytes encoded as specified in - * {@link protos.google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. As - * with all bytes fields, proto buffers use a pure binary representation, - * whereas JSON representations use base64. - * @param {string} request.uri - * URI that points to a file that contains audio data bytes as specified in - * {@link protos.google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. The file - * must not be compressed (for example, gzip). Currently, only Google Cloud - * Storage URIs are supported, which must be specified in the following - * format: `gs://bucket_name/object_name` (other URI formats return - * {@link protos.google.rpc.Code.INVALID_ARGUMENT|INVALID_ARGUMENT}). For more - * information, see [Request - * URIs](https://cloud.google.com/storage/docs/reference-uris). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.RecognizeResponse|RecognizeResponse}. - * Please see the {@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/speech.recognize.js - * region_tag:speech_v2_generated_Speech_Recognize_async - */ + /** + * Performs synchronous Speech recognition: receive results after all audio + * has been sent and processed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.recognizer + * Required. The name of the Recognizer to use during recognition. The + * expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. The + * {recognizer} segment may be set to `_` to use an empty implicit Recognizer. + * @param {google.cloud.speech.v2.RecognitionConfig} request.config + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * {@link protos.google.cloud.speech.v2.RecognizeRequest.config_mask|config_mask} field + * can be used to override parts of the + * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the Recognizer resource. + * @param {google.protobuf.FieldMask} request.configMask + * The list of fields in + * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} that override the + * values in the + * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the recognizer during this recognition request. If no mask is provided, + * all non-default valued fields in + * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * {@link protos.google.cloud.speech.v2.RecognizeRequest.config|config} completely + * overrides and replaces the config in the recognizer for this recognition + * request. + * @param {Buffer} request.content + * The audio data bytes encoded as specified in + * {@link protos.google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. As + * with all bytes fields, proto buffers use a pure binary representation, + * whereas JSON representations use base64. + * @param {string} request.uri + * URI that points to a file that contains audio data bytes as specified in + * {@link protos.google.cloud.speech.v2.RecognitionConfig|RecognitionConfig}. The file + * must not be compressed (for example, gzip). Currently, only Google Cloud + * Storage URIs are supported, which must be specified in the following + * format: `gs://bucket_name/object_name` (other URI formats return + * {@link protos.google.rpc.Code.INVALID_ARGUMENT|INVALID_ARGUMENT}). For more + * information, see [Request + * URIs](https://cloud.google.com/storage/docs/reference-uris). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.RecognizeResponse|RecognizeResponse}. + * Please see the {@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/speech.recognize.js + * region_tag:speech_v2_generated_Speech_Recognize_async + */ recognize( - request?: protos.google.cloud.speech.v2.IRecognizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | undefined, + {} | undefined, + ] + >; recognize( - request: protos.google.cloud.speech.v2.IRecognizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IRecognizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request: protos.google.cloud.speech.v2.IRecognizeRequest, - callback: Callback< - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IRecognizeRequest, + callback: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): void; recognize( - request?: protos.google.cloud.speech.v2.IRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'recognizer': request.recognizer ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + recognizer: request.recognizer ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('recognize request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('recognize response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.recognize(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.IRecognizeResponse, - protos.google.cloud.speech.v2.IRecognizeRequest|undefined, - {}|undefined - ]) => { - this._log.info('recognize response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .recognize(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.IRecognizeResponse, + protos.google.cloud.speech.v2.IRecognizeRequest | undefined, + {} | undefined, + ]) => { + this._log.info('recognize response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 requested {@link protos.google.cloud.speech.v2.Config|Config}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the config to retrieve. There is exactly one config - * resource per project per location. The expected format is - * `projects/{project}/locations/{location}/config`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.Config|Config}. - * Please see the {@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/speech.get_config.js - * region_tag:speech_v2_generated_Speech_GetConfig_async - */ + /** + * Returns the requested {@link protos.google.cloud.speech.v2.Config|Config}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the config to retrieve. There is exactly one config + * resource per project per location. The expected format is + * `projects/{project}/locations/{location}/config`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.Config|Config}. + * Please see the {@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/speech.get_config.js + * region_tag:speech_v2_generated_Speech_GetConfig_async + */ getConfig( - request?: protos.google.cloud.speech.v2.IGetConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IGetConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | undefined, + {} | undefined, + ] + >; getConfig( - request: protos.google.cloud.speech.v2.IGetConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getConfig( - request: protos.google.cloud.speech.v2.IGetConfigRequest, - callback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetConfigRequest, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; getConfig( - request?: protos.google.cloud.speech.v2.IGetConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IGetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IGetConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IGetConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 {@link protos.google.cloud.speech.v2.Config|Config}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.Config} request.config - * Required. The config to update. - * - * The config's `name` field is used to identify the config to be updated. - * The expected format is `projects/{project}/locations/{location}/config`. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields 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 {@link protos.google.cloud.speech.v2.Config|Config}. - * Please see the {@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/speech.update_config.js - * region_tag:speech_v2_generated_Speech_UpdateConfig_async - */ + /** + * Updates the {@link protos.google.cloud.speech.v2.Config|Config}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Config} request.config + * Required. The config to update. + * + * The config's `name` field is used to identify the config to be updated. + * The expected format is `projects/{project}/locations/{location}/config`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields 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 {@link protos.google.cloud.speech.v2.Config|Config}. + * Please see the {@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/speech.update_config.js + * region_tag:speech_v2_generated_Speech_UpdateConfig_async + */ updateConfig( - request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | undefined, + {} | undefined, + ] + >; updateConfig( - request: protos.google.cloud.speech.v2.IUpdateConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateConfig( - request: protos.google.cloud.speech.v2.IUpdateConfigRequest, - callback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateConfigRequest, + callback: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + >, + ): void; updateConfig( - request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IUpdateConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'config.name': request.config!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'config.name': request.config!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.IConfig, - protos.google.cloud.speech.v2.IUpdateConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.IConfig, + protos.google.cloud.speech.v2.IUpdateConfigRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 requested - * {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the CustomClass to retrieve. The expected format is - * `projects/{project}/locations/{location}/customClasses/{custom_class}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * Please see the {@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/speech.get_custom_class.js - * region_tag:speech_v2_generated_Speech_GetCustomClass_async - */ + /** + * Returns the requested + * {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to retrieve. The expected format is + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * Please see the {@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/speech.get_custom_class.js + * region_tag:speech_v2_generated_Speech_GetCustomClass_async + */ getCustomClass( - request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | undefined, + {} | undefined, + ] + >; getCustomClass( - request: protos.google.cloud.speech.v2.IGetCustomClassRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetCustomClassRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request: protos.google.cloud.speech.v2.IGetCustomClassRequest, - callback: Callback< - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetCustomClassRequest, + callback: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): void; getCustomClass( - request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IGetCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.speech.v2.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCustomClass request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.ICustomClass, + | protos.google.cloud.speech.v2.IGetCustomClassRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCustomClass response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCustomClass(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.ICustomClass, - protos.google.cloud.speech.v2.IGetCustomClassRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCustomClass response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCustomClass(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IGetCustomClassRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCustomClass response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 requested - * {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the PhraseSet to retrieve. The expected format is - * `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * Please see the {@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/speech.get_phrase_set.js - * region_tag:speech_v2_generated_Speech_GetPhraseSet_async - */ + /** + * Returns the requested + * {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to retrieve. The expected format is + * `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * Please see the {@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/speech.get_phrase_set.js + * region_tag:speech_v2_generated_Speech_GetPhraseSet_async + */ getPhraseSet( - request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + >; getPhraseSet( - request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, - callback: Callback< - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + callback: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): void; getPhraseSet( - request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.speech.v2.IGetPhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getPhraseSet request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getPhraseSet response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getPhraseSet(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.speech.v2.IPhraseSet, - protos.google.cloud.speech.v2.IGetPhraseSetRequest|undefined, - {}|undefined - ]) => { - this._log.info('getPhraseSet response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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; + return this.innerApiCalls + .getPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IGetPhraseSetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getPhraseSet response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Performs bidirectional streaming speech recognition: receive results while - * sending audio. This method is only available via the gRPC API (not REST). - * - * @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.speech.v2.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and - * will emit objects representing {@link protos.google.cloud.speech.v2.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v2/speech.streaming_recognize.js - * region_tag:speech_v2_generated_Speech_StreamingRecognize_async - */ - _streamingRecognize( - options?: CallOptions): - gax.CancellableStream { - this.initialize().catch(err => {throw err}); + /** + * Performs bidirectional streaming speech recognition: receive results while + * sending audio. This method is only available via the gRPC API (not REST). + * + * @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.speech.v2.StreamingRecognizeRequest|StreamingRecognizeRequest} for write() method, and + * will emit objects representing {@link protos.google.cloud.speech.v2.StreamingRecognizeResponse|StreamingRecognizeResponse} 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/v2/speech.streaming_recognize.js + * region_tag:speech_v2_generated_Speech_StreamingRecognize_async + */ + _streamingRecognize(options?: CallOptions): gax.CancellableStream { + this.initialize().catch((err) => { + throw err; + }); this._log.info('streamingRecognize stream %j', options); return this.innerApiCalls.streamingRecognize(null, options); } -/** - * Creates a {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.Recognizer} request.recognizer - * Required. The Recognizer to create. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the Recognizer, but do not - * actually create it. - * @param {string} request.recognizerId - * The ID to use for the Recognizer, which will become the final component of - * the Recognizer's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link protos.0-9|a-z}-/. - * @param {string} request.parent - * Required. The project and location where this Recognizer will be created. - * The expected format is `projects/{project}/locations/{location}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.create_recognizer.js - * region_tag:speech_v2_generated_Speech_CreateRecognizer_async - */ + /** + * Creates a {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Recognizer} request.recognizer + * Required. The Recognizer to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the Recognizer, but do not + * actually create it. + * @param {string} request.recognizerId + * The ID to use for the Recognizer, which will become the final component of + * the Recognizer's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link protos.0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this Recognizer will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.create_recognizer.js + * region_tag:speech_v2_generated_Speech_CreateRecognizer_async + */ createRecognizer( - request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createRecognizer( - request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createRecognizer( - request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createRecognizer( - request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.ICreateRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.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.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createRecognizer response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createRecognizer request %j', request); - return this.innerApiCalls.createRecognizer(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createRecognizer response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createRecognizer(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createRecognizer response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createRecognizer()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.create_recognizer.js - * region_tag:speech_v2_generated_Speech_CreateRecognizer_async - */ - async checkCreateRecognizerProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.create_recognizer.js + * region_tag:speech_v2_generated_Speech_CreateRecognizer_async + */ + async checkCreateRecognizerProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('createRecognizer long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createRecognizer, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createRecognizer, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Updates the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.Recognizer} request.recognizer - * Required. The Recognizer to update. - * - * The Recognizer's `name` field is used to identify the Recognizer to update. - * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to update. If empty, all non-default valued fields are - * considered for update. Use `*` to update the entire Recognizer resource. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the updated Recognizer, but do not - * actually update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.update_recognizer.js - * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async - */ + /** + * Updates the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.Recognizer} request.recognizer + * Required. The Recognizer to update. + * + * The Recognizer's `name` field is used to identify the Recognizer to update. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire Recognizer resource. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated Recognizer, but do not + * actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.update_recognizer.js + * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async + */ updateRecognizer( - request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateRecognizer( - request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateRecognizer( - request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateRecognizer( - request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUpdateRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.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({ - 'recognizer.name': request.recognizer!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'recognizer.name': request.recognizer!.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.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateRecognizer response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateRecognizer request %j', request); - return this.innerApiCalls.updateRecognizer(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateRecognizer response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateRecognizer(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateRecognizer response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateRecognizer()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.update_recognizer.js - * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async - */ - async checkUpdateRecognizerProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.update_recognizer.js + * region_tag:speech_v2_generated_Speech_UpdateRecognizer_async + */ + async checkUpdateRecognizerProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('updateRecognizer long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateRecognizer, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateRecognizer, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Deletes the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Recognizer to delete. - * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the deleted Recognizer, but do not - * actually delete it. - * @param {boolean} request.allowMissing - * If set to true, and the Recognizer is not found, the request will succeed - * and be a no-op (no Operation is recorded in this case). - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.delete_recognizer.js - * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async - */ + /** + * Deletes the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to delete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted Recognizer, but do not + * actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the Recognizer is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.delete_recognizer.js + * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async + */ deleteRecognizer( - request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteRecognizer( - request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteRecognizer( - request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteRecognizer( - request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IDeleteRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.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.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteRecognizer response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteRecognizer request %j', request); - return this.innerApiCalls.deleteRecognizer(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteRecognizer response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteRecognizer(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteRecognizer response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteRecognizer()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.delete_recognizer.js - * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async - */ - async checkDeleteRecognizerProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.delete_recognizer.js + * region_tag:speech_v2_generated_Speech_DeleteRecognizer_async + */ + async checkDeleteRecognizerProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('deleteRecognizer long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteRecognizer, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteRecognizer, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Undeletes the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the Recognizer to undelete. - * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the undeleted Recognizer, but do - * not actually undelete it. - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.undelete_recognizer.js - * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async - */ + /** + * Undeletes the {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the Recognizer to undelete. + * Format: `projects/{project}/locations/{location}/recognizers/{recognizer}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted Recognizer, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.undelete_recognizer.js + * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async + */ undeleteRecognizer( - request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; undeleteRecognizer( - request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeleteRecognizer( - request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeleteRecognizer( - request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUndeleteRecognizerRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.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.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('undeleteRecognizer response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('undeleteRecognizer request %j', request); - return this.innerApiCalls.undeleteRecognizer(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('undeleteRecognizer response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .undeleteRecognizer(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('undeleteRecognizer response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `undeleteRecognizer()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.undelete_recognizer.js - * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async - */ - async checkUndeleteRecognizerProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `undeleteRecognizer()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.undelete_recognizer.js + * region_tag:speech_v2_generated_Speech_UndeleteRecognizer_async + */ + async checkUndeleteRecognizerProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('undeleteRecognizer long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeleteRecognizer, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.undeleteRecognizer, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.Recognizer, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Performs batch asynchronous speech recognition: send a request with N - * audio files and receive a long running operation that can be polled to see - * when the transcriptions are finished. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.recognizer - * Required. The name of the Recognizer to use during recognition. The - * expected format is - * `projects/{project}/locations/{location}/recognizers/{recognizer}`. The - * {recognizer} segment may be set to `_` to use an empty implicit Recognizer. - * @param {google.cloud.speech.v2.RecognitionConfig} request.config - * Features and audio metadata to use for the Automatic Speech Recognition. - * This field in combination with the - * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config_mask|config_mask} - * field can be used to override parts of the - * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} - * of the Recognizer resource. - * @param {google.protobuf.FieldMask} request.configMask - * The list of fields in - * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} that override - * the values in the - * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} - * of the recognizer during this recognition request. If no mask is provided, - * all given fields in - * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} override the - * values in the recognizer for this recognition request. If a mask is - * provided, only the fields listed in the mask override the config in the - * recognizer for this recognition request. If a wildcard (`*`) is provided, - * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} completely - * overrides and replaces the config in the recognizer for this recognition - * request. - * @param {number[]} request.files - * Audio files with file metadata for ASR. - * The maximum number of files allowed to be specified is 15. - * @param {google.cloud.speech.v2.RecognitionOutputConfig} request.recognitionOutputConfig - * Configuration options for where to output the transcripts of each file. - * @param {google.cloud.speech.v2.BatchRecognizeRequest.ProcessingStrategy} request.processingStrategy - * Processing strategy to use for this 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.batch_recognize.js - * region_tag:speech_v2_generated_Speech_BatchRecognize_async - */ + /** + * Performs batch asynchronous speech recognition: send a request with N + * audio files and receive a long running operation that can be polled to see + * when the transcriptions are finished. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.recognizer + * Required. The name of the Recognizer to use during recognition. The + * expected format is + * `projects/{project}/locations/{location}/recognizers/{recognizer}`. The + * {recognizer} segment may be set to `_` to use an empty implicit Recognizer. + * @param {google.cloud.speech.v2.RecognitionConfig} request.config + * Features and audio metadata to use for the Automatic Speech Recognition. + * This field in combination with the + * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config_mask|config_mask} + * field can be used to override parts of the + * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the Recognizer resource. + * @param {google.protobuf.FieldMask} request.configMask + * The list of fields in + * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} that override + * the values in the + * {@link protos.google.cloud.speech.v2.Recognizer.default_recognition_config|default_recognition_config} + * of the recognizer during this recognition request. If no mask is provided, + * all given fields in + * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} override the + * values in the recognizer for this recognition request. If a mask is + * provided, only the fields listed in the mask override the config in the + * recognizer for this recognition request. If a wildcard (`*`) is provided, + * {@link protos.google.cloud.speech.v2.BatchRecognizeRequest.config|config} completely + * overrides and replaces the config in the recognizer for this recognition + * request. + * @param {number[]} request.files + * Audio files with file metadata for ASR. + * The maximum number of files allowed to be specified is 15. + * @param {google.cloud.speech.v2.RecognitionOutputConfig} request.recognitionOutputConfig + * Configuration options for where to output the transcripts of each file. + * @param {google.cloud.speech.v2.BatchRecognizeRequest.ProcessingStrategy} request.processingStrategy + * Processing strategy to use for this 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.batch_recognize.js + * region_tag:speech_v2_generated_Speech_BatchRecognize_async + */ batchRecognize( - request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchRecognize( - request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchRecognize( - request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchRecognize( - request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IBatchRecognizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.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({ - 'recognizer': request.recognizer ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + recognizer: request.recognizer ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().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.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchRecognize response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchRecognize request %j', request); - return this.innerApiCalls.batchRecognize(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchRecognize response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchRecognize(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchRecognize response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchRecognize()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.batch_recognize.js - * region_tag:speech_v2_generated_Speech_BatchRecognize_async - */ - async checkBatchRecognizeProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchRecognize()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.batch_recognize.js + * region_tag:speech_v2_generated_Speech_BatchRecognize_async + */ + async checkBatchRecognizeProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.BatchRecognizeResponse, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('batchRecognize long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchRecognize, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchRecognize, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.BatchRecognizeResponse, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Creates a {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.CustomClass} request.customClass - * Required. The CustomClass to create. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the CustomClass, but do not - * actually create it. - * @param {string} request.customClassId - * The ID to use for the CustomClass, which will become the final component of - * the CustomClass's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link protos.0-9|a-z}-/. - * @param {string} request.parent - * Required. The project and location where this CustomClass will be created. - * The expected format is `projects/{project}/locations/{location}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.create_custom_class.js - * region_tag:speech_v2_generated_Speech_CreateCustomClass_async - */ + /** + * Creates a {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.CustomClass} request.customClass + * Required. The CustomClass to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the CustomClass, but do not + * actually create it. + * @param {string} request.customClassId + * The ID to use for the CustomClass, which will become the final component of + * the CustomClass's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link protos.0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this CustomClass will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.create_custom_class.js + * region_tag:speech_v2_generated_Speech_CreateCustomClass_async + */ createCustomClass( - request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createCustomClass( - request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createCustomClass( - request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.ICreateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.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.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createCustomClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createCustomClass request %j', request); - return this.innerApiCalls.createCustomClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createCustomClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createCustomClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createCustomClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createCustomClass()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.create_custom_class.js - * region_tag:speech_v2_generated_Speech_CreateCustomClass_async - */ - async checkCreateCustomClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.create_custom_class.js + * region_tag:speech_v2_generated_Speech_CreateCustomClass_async + */ + async checkCreateCustomClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('createCustomClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createCustomClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createCustomClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Updates the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.CustomClass} request.customClass - * Required. The CustomClass to update. - * - * The CustomClass's `name` field is used to identify the CustomClass to - * update. Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}`. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to be updated. If empty, all fields are considered for - * update. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the updated CustomClass, but do - * not actually update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.update_custom_class.js - * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async - */ + /** + * Updates the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.CustomClass} request.customClass + * Required. The CustomClass to update. + * + * The CustomClass's `name` field is used to identify the CustomClass to + * update. Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to be updated. If empty, all fields are considered for + * update. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated CustomClass, but do + * not actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.update_custom_class.js + * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async + */ updateCustomClass( - request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateCustomClass( - request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateCustomClass( - request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUpdateCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.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({ - 'custom_class.name': request.customClass!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'custom_class.name': request.customClass!.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.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateCustomClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateCustomClass request %j', request); - return this.innerApiCalls.updateCustomClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateCustomClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateCustomClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateCustomClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateCustomClass()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.update_custom_class.js - * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async - */ - async checkUpdateCustomClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.update_custom_class.js + * region_tag:speech_v2_generated_Speech_UpdateCustomClass_async + */ + async checkUpdateCustomClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('updateCustomClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateCustomClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateCustomClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Deletes the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the CustomClass to delete. - * Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the deleted CustomClass, but do - * not actually delete it. - * @param {boolean} request.allowMissing - * If set to true, and the CustomClass is not found, the request will succeed - * and be a no-op (no Operation is recorded in this case). - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.delete_custom_class.js - * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async - */ + /** + * Deletes the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to delete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted CustomClass, but do + * not actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the CustomClass is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.delete_custom_class.js + * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async + */ deleteCustomClass( - request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteCustomClass( - request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteCustomClass( - request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IDeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.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.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteCustomClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteCustomClass request %j', request); - return this.innerApiCalls.deleteCustomClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteCustomClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteCustomClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCustomClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteCustomClass()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.delete_custom_class.js - * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async - */ - async checkDeleteCustomClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.delete_custom_class.js + * region_tag:speech_v2_generated_Speech_DeleteCustomClass_async + */ + async checkDeleteCustomClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('deleteCustomClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteCustomClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteCustomClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Undeletes the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the CustomClass to undelete. - * Format: - * `projects/{project}/locations/{location}/customClasses/{custom_class}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the undeleted CustomClass, but do - * not actually undelete it. - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.undelete_custom_class.js - * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async - */ + /** + * Undeletes the {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the CustomClass to undelete. + * Format: + * `projects/{project}/locations/{location}/customClasses/{custom_class}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted CustomClass, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.undelete_custom_class.js + * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async + */ undeleteCustomClass( - request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; undeleteCustomClass( - request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeleteCustomClass( - request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeleteCustomClass( - request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUndeleteCustomClassRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.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.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('undeleteCustomClass response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('undeleteCustomClass request %j', request); - return this.innerApiCalls.undeleteCustomClass(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('undeleteCustomClass response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .undeleteCustomClass(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('undeleteCustomClass response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `undeleteCustomClass()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.undelete_custom_class.js - * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async - */ - async checkUndeleteCustomClassProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `undeleteCustomClass()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.undelete_custom_class.js + * region_tag:speech_v2_generated_Speech_UndeleteCustomClass_async + */ + async checkUndeleteCustomClassProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('undeleteCustomClass long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeleteCustomClass, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.undeleteCustomClass, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.CustomClass, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Creates a {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet - * Required. The PhraseSet to create. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the PhraseSet, but do not - * actually create it. - * @param {string} request.phraseSetId - * The ID to use for the PhraseSet, which will become the final component of - * the PhraseSet's resource name. - * - * This value should be 4-63 characters, and valid characters - * are /{@link protos.0-9|a-z}-/. - * @param {string} request.parent - * Required. The project and location where this PhraseSet will be created. - * The expected format is `projects/{project}/locations/{location}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.create_phrase_set.js - * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async - */ + /** + * Creates a {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet + * Required. The PhraseSet to create. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the PhraseSet, but do not + * actually create it. + * @param {string} request.phraseSetId + * The ID to use for the PhraseSet, which will become the final component of + * the PhraseSet's resource name. + * + * This value should be 4-63 characters, and valid characters + * are /{@link protos.0-9|a-z}-/. + * @param {string} request.parent + * Required. The project and location where this PhraseSet will be created. + * The expected format is `projects/{project}/locations/{location}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.create_phrase_set.js + * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async + */ createPhraseSet( - request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createPhraseSet( - request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createPhraseSet( - request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.ICreatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.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.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createPhraseSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createPhraseSet request %j', request); - return this.innerApiCalls.createPhraseSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createPhraseSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createPhraseSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createPhraseSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createPhraseSet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.create_phrase_set.js - * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async - */ - async checkCreatePhraseSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createPhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.create_phrase_set.js + * region_tag:speech_v2_generated_Speech_CreatePhraseSet_async + */ + async checkCreatePhraseSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('createPhraseSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createPhraseSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createPhraseSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Updates the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet - * Required. The PhraseSet to update. - * - * The PhraseSet's `name` field is used to identify the PhraseSet to update. - * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields to update. If empty, all non-default valued fields are - * considered for update. Use `*` to update the entire PhraseSet resource. - * @param {boolean} request.validateOnly - * If set, validate the request and preview the updated PhraseSet, but do not - * actually update it. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link 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/speech.update_phrase_set.js - * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async - */ + /** + * Updates the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.speech.v2.PhraseSet} request.phraseSet + * Required. The PhraseSet to update. + * + * The PhraseSet's `name` field is used to identify the PhraseSet to update. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}`. + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields to update. If empty, all non-default valued fields are + * considered for update. Use `*` to update the entire PhraseSet resource. + * @param {boolean} request.validateOnly + * If set, validate the request and preview the updated PhraseSet, but do not + * actually update it. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link 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/speech.update_phrase_set.js + * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async + */ updatePhraseSet( - request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updatePhraseSet( - request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updatePhraseSet( - request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUpdatePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.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({ - 'phrase_set.name': request.phraseSet!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'phrase_set.name': request.phraseSet!.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.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updatePhraseSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updatePhraseSet request %j', request); - return this.innerApiCalls.updatePhraseSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updatePhraseSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updatePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updatePhraseSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updatePhraseSet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.update_phrase_set.js - * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async - */ - async checkUpdatePhraseSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updatePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.update_phrase_set.js + * region_tag:speech_v2_generated_Speech_UpdatePhraseSet_async + */ + async checkUpdatePhraseSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('updatePhraseSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updatePhraseSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updatePhraseSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Deletes the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the PhraseSet to delete. - * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the deleted PhraseSet, but do not - * actually delete it. - * @param {boolean} request.allowMissing - * If set to true, and the PhraseSet is not found, the request will succeed - * and be a no-op (no Operation is recorded in this case). - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.delete_phrase_set.js - * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async - */ + /** + * Deletes the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to delete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the deleted PhraseSet, but do not + * actually delete it. + * @param {boolean} request.allowMissing + * If set to true, and the PhraseSet is not found, the request will succeed + * and be a no-op (no Operation is recorded in this case). + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.delete_phrase_set.js + * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async + */ deletePhraseSet( - request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deletePhraseSet( - request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deletePhraseSet( - request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IDeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.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.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deletePhraseSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deletePhraseSet request %j', request); - return this.innerApiCalls.deletePhraseSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deletePhraseSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deletePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deletePhraseSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deletePhraseSet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.delete_phrase_set.js - * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async - */ - async checkDeletePhraseSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deletePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.delete_phrase_set.js + * region_tag:speech_v2_generated_Speech_DeletePhraseSet_async + */ + async checkDeletePhraseSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('deletePhraseSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deletePhraseSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deletePhraseSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; } -/** - * Undeletes the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the PhraseSet to undelete. - * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` - * @param {boolean} request.validateOnly - * If set, validate the request and preview the undeleted PhraseSet, but do - * not actually undelete it. - * @param {string} request.etag - * This checksum is computed by the server based on the value of other - * fields. This may be sent on update, undelete, 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/v2/speech.undelete_phrase_set.js - * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async - */ + /** + * Undeletes the {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the PhraseSet to undelete. + * Format: `projects/{project}/locations/{location}/phraseSets/{phrase_set}` + * @param {boolean} request.validateOnly + * If set, validate the request and preview the undeleted PhraseSet, but do + * not actually undelete it. + * @param {string} request.etag + * This checksum is computed by the server based on the value of other + * fields. This may be sent on update, undelete, 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/v2/speech.undelete_phrase_set.js + * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async + */ undeletePhraseSet( - request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; undeletePhraseSet( - request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeletePhraseSet( - request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + callback: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; undeletePhraseSet( - request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.speech.v2.IUndeletePhraseSetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.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.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('undeletePhraseSet response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('undeletePhraseSet request %j', request); - return this.innerApiCalls.undeletePhraseSet(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('undeletePhraseSet response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .undeletePhraseSet(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('undeletePhraseSet response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `undeletePhraseSet()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link 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/speech.undelete_phrase_set.js - * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async - */ - async checkUndeletePhraseSetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `undeletePhraseSet()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link 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/speech.undelete_phrase_set.js + * region_tag:speech_v2_generated_Speech_UndeletePhraseSet_async + */ + async checkUndeletePhraseSetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + > + > { this._log.info('undeletePhraseSet long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.undeletePhraseSet, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists Recognizers. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location of Recognizers to list. The expected - * format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of Recognizers to return. The service may return fewer - * than this value. If unspecified, at most 5 Recognizers will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. - * 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 `listRecognizersAsync()` - * method described below for async iteration which you can stop as 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.undeletePhraseSet, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.speech.v2.PhraseSet, + protos.google.cloud.speech.v2.OperationMetadata + >; + } + /** + * Lists Recognizers. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 5 Recognizers will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.Recognizer|Recognizer}. + * 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 `listRecognizersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRecognizers( - request?: protos.google.cloud.speech.v2.IListRecognizersRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IRecognizer[], - protos.google.cloud.speech.v2.IListRecognizersRequest|null, - protos.google.cloud.speech.v2.IListRecognizersResponse - ]>; + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer[], + protos.google.cloud.speech.v2.IListRecognizersRequest | null, + protos.google.cloud.speech.v2.IListRecognizersResponse, + ] + >; listRecognizers( - request: protos.google.cloud.speech.v2.IListRecognizersRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListRecognizersRequest, - protos.google.cloud.speech.v2.IListRecognizersResponse|null|undefined, - protos.google.cloud.speech.v2.IRecognizer>): void; + request: protos.google.cloud.speech.v2.IListRecognizersRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + >, + ): void; listRecognizers( - request: protos.google.cloud.speech.v2.IListRecognizersRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListRecognizersRequest, - protos.google.cloud.speech.v2.IListRecognizersResponse|null|undefined, - protos.google.cloud.speech.v2.IRecognizer>): void; + request: protos.google.cloud.speech.v2.IListRecognizersRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + >, + ): void; listRecognizers( - request?: protos.google.cloud.speech.v2.IListRecognizersRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v2.IListRecognizersRequest, - protos.google.cloud.speech.v2.IListRecognizersResponse|null|undefined, - protos.google.cloud.speech.v2.IRecognizer>, - callback?: PaginationCallback< + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v2.IListRecognizersRequest, - protos.google.cloud.speech.v2.IListRecognizersResponse|null|undefined, - protos.google.cloud.speech.v2.IRecognizer>): - Promise<[ - protos.google.cloud.speech.v2.IRecognizer[], - protos.google.cloud.speech.v2.IListRecognizersRequest|null, - protos.google.cloud.speech.v2.IListRecognizersResponse - ]>|void { + | protos.google.cloud.speech.v2.IListRecognizersResponse + | null + | undefined, + protos.google.cloud.speech.v2.IRecognizer + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + protos.google.cloud.speech.v2.IListRecognizersResponse | null | undefined, + protos.google.cloud.speech.v2.IRecognizer + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IRecognizer[], + protos.google.cloud.speech.v2.IListRecognizersRequest | null, + protos.google.cloud.speech.v2.IListRecognizersResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v2.IListRecognizersRequest, - protos.google.cloud.speech.v2.IListRecognizersResponse|null|undefined, - protos.google.cloud.speech.v2.IRecognizer>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v2.IListRecognizersRequest, + | protos.google.cloud.speech.v2.IListRecognizersResponse + | null + | undefined, + protos.google.cloud.speech.v2.IRecognizer + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listRecognizers values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2793,223 +3962,252 @@ export class SpeechClient { this._log.info('listRecognizers request %j', request); return this.innerApiCalls .listRecognizers(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v2.IRecognizer[], - protos.google.cloud.speech.v2.IListRecognizersRequest|null, - protos.google.cloud.speech.v2.IListRecognizersResponse - ]) => { - this._log.info('listRecognizers values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v2.IRecognizer[], + protos.google.cloud.speech.v2.IListRecognizersRequest | null, + protos.google.cloud.speech.v2.IListRecognizersResponse, + ]) => { + this._log.info('listRecognizers values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listRecognizers`, 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 of Recognizers to list. The expected - * format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of Recognizers to return. The service may return fewer - * than this value. If unspecified, at most 5 Recognizers will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.Recognizer|Recognizer} 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 `listRecognizersAsync()` - * method described below for async iteration which you can stop as 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 `listRecognizers`, 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 of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 5 Recognizers will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.Recognizer|Recognizer} 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 `listRecognizersAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listRecognizersStream( - request?: protos.google.cloud.speech.v2.IListRecognizersRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + 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['listRecognizers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRecognizers stream %j', request); return this.descriptors.page.listRecognizers.createStream( this.innerApiCalls.listRecognizers as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listRecognizers`, 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 of Recognizers to list. The expected - * format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of Recognizers to return. The service may return fewer - * than this value. If unspecified, at most 5 Recognizers will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {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.speech.v2.Recognizer|Recognizer}. 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/speech.list_recognizers.js - * region_tag:speech_v2_generated_Speech_ListRecognizers_async - */ + /** + * Equivalent to `listRecognizers`, 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 of Recognizers to list. The expected + * format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of Recognizers to return. The service may return fewer + * than this value. If unspecified, at most 5 Recognizers will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListRecognizers|ListRecognizers} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {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.speech.v2.Recognizer|Recognizer}. 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/speech.list_recognizers.js + * region_tag:speech_v2_generated_Speech_ListRecognizers_async + */ listRecognizersAsync( - request?: protos.google.cloud.speech.v2.IListRecognizersRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v2.IListRecognizersRequest, + 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['listRecognizers']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listRecognizers iterate %j', request); return this.descriptors.page.listRecognizers.asyncIterate( this.innerApiCalls['listRecognizers'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists CustomClasses. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location of CustomClass resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Number of results per requests. A valid page_size ranges from 0 to 100 - * inclusive. If the page_size is zero or unspecified, a page size of 5 will - * be chosen. If the page size exceeds 100, it will be coerced down to 100. - * Note that a call might return fewer results than the requested page size. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must - * match the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. - * 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 CustomClasses. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 100 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 100, it will be coerced down to 100. + * Note that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.CustomClass|CustomClass}. + * 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClasses( - request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.ICustomClass[], - protos.google.cloud.speech.v2.IListCustomClassesRequest|null, - protos.google.cloud.speech.v2.IListCustomClassesResponse - ]>; + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass[], + protos.google.cloud.speech.v2.IListCustomClassesRequest | null, + protos.google.cloud.speech.v2.IListCustomClassesResponse, + ] + >; listCustomClasses( - request: protos.google.cloud.speech.v2.IListCustomClassesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListCustomClassesRequest, - protos.google.cloud.speech.v2.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v2.ICustomClass>): void; + request: protos.google.cloud.speech.v2.IListCustomClassesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + >, + ): void; listCustomClasses( - request: protos.google.cloud.speech.v2.IListCustomClassesRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListCustomClassesRequest, - protos.google.cloud.speech.v2.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v2.ICustomClass>): void; + request: protos.google.cloud.speech.v2.IListCustomClassesRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + >, + ): void; listCustomClasses( - request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v2.IListCustomClassesRequest, - protos.google.cloud.speech.v2.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v2.ICustomClass>, - callback?: PaginationCallback< + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v2.IListCustomClassesRequest, - protos.google.cloud.speech.v2.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v2.ICustomClass>): - Promise<[ - protos.google.cloud.speech.v2.ICustomClass[], - protos.google.cloud.speech.v2.IListCustomClassesRequest|null, - protos.google.cloud.speech.v2.IListCustomClassesResponse - ]>|void { + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + >, + ): Promise< + [ + protos.google.cloud.speech.v2.ICustomClass[], + protos.google.cloud.speech.v2.IListCustomClassesRequest | null, + protos.google.cloud.speech.v2.IListCustomClassesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v2.IListCustomClassesRequest, - protos.google.cloud.speech.v2.IListCustomClassesResponse|null|undefined, - protos.google.cloud.speech.v2.ICustomClass>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v2.IListCustomClassesRequest, + | protos.google.cloud.speech.v2.IListCustomClassesResponse + | null + | undefined, + protos.google.cloud.speech.v2.ICustomClass + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCustomClasses values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3018,224 +4216,247 @@ export class SpeechClient { this._log.info('listCustomClasses request %j', request); return this.innerApiCalls .listCustomClasses(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v2.ICustomClass[], - protos.google.cloud.speech.v2.IListCustomClassesRequest|null, - protos.google.cloud.speech.v2.IListCustomClassesResponse - ]) => { - this._log.info('listCustomClasses values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v2.ICustomClass[], + protos.google.cloud.speech.v2.IListCustomClassesRequest | null, + protos.google.cloud.speech.v2.IListCustomClassesResponse, + ]) => { + this._log.info('listCustomClasses values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCustomClasses`, 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 of CustomClass resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Number of results per requests. A valid page_size ranges from 0 to 100 - * inclusive. If the page_size is zero or unspecified, a page size of 5 will - * be chosen. If the page size exceeds 100, it will be coerced down to 100. - * Note that a call might return fewer results than the requested page size. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must - * match the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.CustomClass|CustomClass} 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 `listCustomClassesAsync()` - * method described below for async iteration which you can stop as 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 `listCustomClasses`, 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 of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 100 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 100, it will be coerced down to 100. + * Note that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.CustomClass|CustomClass} 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 `listCustomClassesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCustomClassesStream( - request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses stream %j', request); return this.descriptors.page.listCustomClasses.createStream( this.innerApiCalls.listCustomClasses as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCustomClasses`, 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 of CustomClass resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * Number of results per requests. A valid page_size ranges from 0 to 100 - * inclusive. If the page_size is zero or unspecified, a page size of 5 will - * be chosen. If the page size exceeds 100, it will be coerced down to 100. - * Note that a call might return fewer results than the requested page size. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must - * match the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {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.speech.v2.CustomClass|CustomClass}. 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/speech.list_custom_classes.js - * region_tag:speech_v2_generated_Speech_ListCustomClasses_async - */ + /** + * Equivalent to `listCustomClasses`, 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 of CustomClass resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * Number of results per requests. A valid page_size ranges from 0 to 100 + * inclusive. If the page_size is zero or unspecified, a page size of 5 will + * be chosen. If the page size exceeds 100, it will be coerced down to 100. + * Note that a call might return fewer results than the requested page size. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListCustomClasses|ListCustomClasses} must + * match the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {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.speech.v2.CustomClass|CustomClass}. 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/speech.list_custom_classes.js + * region_tag:speech_v2_generated_Speech_ListCustomClasses_async + */ listCustomClassesAsync( - request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v2.IListCustomClassesRequest, + 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['listCustomClasses']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCustomClasses iterate %j', request); return this.descriptors.page.listCustomClasses.asyncIterate( this.innerApiCalls['listCustomClasses'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists PhraseSets. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and location of PhraseSet resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of PhraseSets to return. The service may return fewer - * than this value. If unspecified, at most 5 PhraseSets will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. - * 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 `listPhraseSetsAsync()` - * method described below for async iteration which you can stop as 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 PhraseSets. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and location of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 5 PhraseSets will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 Array of {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet}. + * 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 `listPhraseSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSets( - request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.speech.v2.IPhraseSet[], - protos.google.cloud.speech.v2.IListPhraseSetsRequest|null, - protos.google.cloud.speech.v2.IListPhraseSetsResponse - ]>; + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet[], + protos.google.cloud.speech.v2.IListPhraseSetsRequest | null, + protos.google.cloud.speech.v2.IListPhraseSetsResponse, + ] + >; listPhraseSets( - request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListPhraseSetsRequest, - protos.google.cloud.speech.v2.IListPhraseSetsResponse|null|undefined, - protos.google.cloud.speech.v2.IPhraseSet>): void; + request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + >, + ): void; listPhraseSets( - request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - callback: PaginationCallback< - protos.google.cloud.speech.v2.IListPhraseSetsRequest, - protos.google.cloud.speech.v2.IListPhraseSetsResponse|null|undefined, - protos.google.cloud.speech.v2.IPhraseSet>): void; + request: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + callback: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + >, + ): void; listPhraseSets( - request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.speech.v2.IListPhraseSetsRequest, - protos.google.cloud.speech.v2.IListPhraseSetsResponse|null|undefined, - protos.google.cloud.speech.v2.IPhraseSet>, - callback?: PaginationCallback< + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.speech.v2.IListPhraseSetsRequest, - protos.google.cloud.speech.v2.IListPhraseSetsResponse|null|undefined, - protos.google.cloud.speech.v2.IPhraseSet>): - Promise<[ - protos.google.cloud.speech.v2.IPhraseSet[], - protos.google.cloud.speech.v2.IListPhraseSetsRequest|null, - protos.google.cloud.speech.v2.IListPhraseSetsResponse - ]>|void { + | protos.google.cloud.speech.v2.IListPhraseSetsResponse + | null + | undefined, + protos.google.cloud.speech.v2.IPhraseSet + >, + callback?: PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + protos.google.cloud.speech.v2.IListPhraseSetsResponse | null | undefined, + protos.google.cloud.speech.v2.IPhraseSet + >, + ): Promise< + [ + protos.google.cloud.speech.v2.IPhraseSet[], + protos.google.cloud.speech.v2.IListPhraseSetsRequest | null, + protos.google.cloud.speech.v2.IListPhraseSetsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.speech.v2.IListPhraseSetsRequest, - protos.google.cloud.speech.v2.IListPhraseSetsResponse|null|undefined, - protos.google.cloud.speech.v2.IPhraseSet>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.speech.v2.IListPhraseSetsRequest, + | protos.google.cloud.speech.v2.IListPhraseSetsResponse + | null + | undefined, + protos.google.cloud.speech.v2.IPhraseSet + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listPhraseSets values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -3244,131 +4465,136 @@ export class SpeechClient { this._log.info('listPhraseSets request %j', request); return this.innerApiCalls .listPhraseSets(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.speech.v2.IPhraseSet[], - protos.google.cloud.speech.v2.IListPhraseSetsRequest|null, - protos.google.cloud.speech.v2.IListPhraseSetsResponse - ]) => { - this._log.info('listPhraseSets values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.speech.v2.IPhraseSet[], + protos.google.cloud.speech.v2.IListPhraseSetsRequest | null, + protos.google.cloud.speech.v2.IListPhraseSetsResponse, + ]) => { + this._log.info('listPhraseSets values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listPhraseSets`, 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 of PhraseSet resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of PhraseSets to return. The service may return fewer - * than this value. If unspecified, at most 5 PhraseSets will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {Stream} - * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet} 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 `listPhraseSetsAsync()` - * method described below for async iteration which you can stop as 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 `listPhraseSets`, 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 of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 5 PhraseSets will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {Stream} + * An object stream which emits an object representing {@link protos.google.cloud.speech.v2.PhraseSet|PhraseSet} 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 `listPhraseSetsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listPhraseSetsStream( - request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + 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['listPhraseSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSets stream %j', request); return this.descriptors.page.listPhraseSets.createStream( this.innerApiCalls.listPhraseSets as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listPhraseSets`, 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 of PhraseSet resources to list. The - * expected format is `projects/{project}/locations/{location}`. - * @param {number} request.pageSize - * The maximum number of PhraseSets to return. The service may return fewer - * than this value. If unspecified, at most 5 PhraseSets will be returned. - * The maximum value is 100; values above 100 will be coerced to 100. - * @param {string} request.pageToken - * A page token, received from a previous - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to - * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match - * the call that provided the page token. - * @param {boolean} request.showDeleted - * Whether, or not, to show resources that 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 {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.speech.v2.PhraseSet|PhraseSet}. 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/speech.list_phrase_sets.js - * region_tag:speech_v2_generated_Speech_ListPhraseSets_async - */ + /** + * Equivalent to `listPhraseSets`, 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 of PhraseSet resources to list. The + * expected format is `projects/{project}/locations/{location}`. + * @param {number} request.pageSize + * The maximum number of PhraseSets to return. The service may return fewer + * than this value. If unspecified, at most 5 PhraseSets will be returned. + * The maximum value is 100; values above 100 will be coerced to 100. + * @param {string} request.pageToken + * A page token, received from a previous + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to + * {@link protos.google.cloud.speech.v2.Speech.ListPhraseSets|ListPhraseSets} must match + * the call that provided the page token. + * @param {boolean} request.showDeleted + * Whether, or not, to show resources that 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 {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.speech.v2.PhraseSet|PhraseSet}. 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/speech.list_phrase_sets.js + * region_tag:speech_v2_generated_Speech_ListPhraseSets_async + */ listPhraseSetsAsync( - request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.speech.v2.IListPhraseSetsRequest, + 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['listPhraseSets']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listPhraseSets iterate %j', request); return this.descriptors.page.listPhraseSets.asyncIterate( this.innerApiCalls['listPhraseSets'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -3403,12 +4629,11 @@ export class SpeechClient { | 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. @@ -3441,12 +4666,12 @@ export class SpeechClient { */ 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. @@ -3489,22 +4714,22 @@ export class SpeechClient { 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); } /** @@ -3539,15 +4764,15 @@ export class SpeechClient { */ 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); } /** @@ -3581,7 +4806,7 @@ export class SpeechClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -3594,25 +4819,24 @@ export class SpeechClient { 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 @@ -3651,22 +4875,22 @@ export class SpeechClient { 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); } @@ -3681,7 +4905,7 @@ export class SpeechClient { * @param {string} location * @returns {string} Resource name string. */ - configPath(project:string,location:string) { + configPath(project: string, location: string) { return this.pathTemplates.configPathTemplate.render({ project: project, location: location, @@ -3719,7 +4943,12 @@ export class SpeechClient { * @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, @@ -3736,7 +4965,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).project; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .project; } /** @@ -3747,7 +4977,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyName(cryptoKeyName: string) { - return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName).location; + return this.pathTemplates.cryptoKeyPathTemplate.match(cryptoKeyName) + .location; } /** @@ -3758,7 +4989,8 @@ export class SpeechClient { * @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; } /** @@ -3769,7 +5001,8 @@ export class SpeechClient { * @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; } /** @@ -3782,7 +5015,13 @@ export class SpeechClient { * @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, @@ -3800,7 +5039,9 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).project; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).project; } /** @@ -3811,7 +5052,9 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromCryptoKeyVersionName(cryptoKeyVersionName: string) { - return this.pathTemplates.cryptoKeyVersionPathTemplate.match(cryptoKeyVersionName).location; + return this.pathTemplates.cryptoKeyVersionPathTemplate.match( + cryptoKeyVersionName, + ).location; } /** @@ -3822,7 +5065,9 @@ export class SpeechClient { * @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; } /** @@ -3833,7 +5078,9 @@ export class SpeechClient { * @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; } /** @@ -3844,7 +5091,9 @@ export class SpeechClient { * @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; } /** @@ -3855,7 +5104,7 @@ export class SpeechClient { * @param {string} custom_class * @returns {string} Resource name string. */ - customClassPath(project:string,location:string,customClass:string) { + customClassPath(project: string, location: string, customClass: string) { return this.pathTemplates.customClassPathTemplate.render({ project: project, location: location, @@ -3871,7 +5120,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).project; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .project; } /** @@ -3882,7 +5132,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).location; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .location; } /** @@ -3893,7 +5144,8 @@ export class SpeechClient { * @returns {string} A string representing the custom_class. */ matchCustomClassFromCustomClassName(customClassName: string) { - return this.pathTemplates.customClassPathTemplate.match(customClassName).custom_class; + return this.pathTemplates.customClassPathTemplate.match(customClassName) + .custom_class; } /** @@ -3903,7 +5155,7 @@ export class SpeechClient { * @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, @@ -3940,7 +5192,7 @@ export class SpeechClient { * @param {string} phrase_set * @returns {string} Resource name string. */ - phraseSetPath(project:string,location:string,phraseSet:string) { + phraseSetPath(project: string, location: string, phraseSet: string) { return this.pathTemplates.phraseSetPathTemplate.render({ project: project, location: location, @@ -3956,7 +5208,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).project; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .project; } /** @@ -3967,7 +5220,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).location; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .location; } /** @@ -3978,7 +5232,8 @@ export class SpeechClient { * @returns {string} A string representing the phrase_set. */ matchPhraseSetFromPhraseSetName(phraseSetName: string) { - return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName).phrase_set; + return this.pathTemplates.phraseSetPathTemplate.match(phraseSetName) + .phrase_set; } /** @@ -3987,7 +5242,7 @@ export class SpeechClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -4012,7 +5267,7 @@ export class SpeechClient { * @param {string} recognizer * @returns {string} Resource name string. */ - recognizerPath(project:string,location:string,recognizer:string) { + recognizerPath(project: string, location: string, recognizer: string) { return this.pathTemplates.recognizerPathTemplate.render({ project: project, location: location, @@ -4028,7 +5283,8 @@ export class SpeechClient { * @returns {string} A string representing the project. */ matchProjectFromRecognizerName(recognizerName: string) { - return this.pathTemplates.recognizerPathTemplate.match(recognizerName).project; + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .project; } /** @@ -4039,7 +5295,8 @@ export class SpeechClient { * @returns {string} A string representing the location. */ matchLocationFromRecognizerName(recognizerName: string) { - return this.pathTemplates.recognizerPathTemplate.match(recognizerName).location; + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .location; } /** @@ -4050,7 +5307,8 @@ export class SpeechClient { * @returns {string} A string representing the recognizer. */ matchRecognizerFromRecognizerName(recognizerName: string) { - return this.pathTemplates.recognizerPathTemplate.match(recognizerName).recognizer; + return this.pathTemplates.recognizerPathTemplate.match(recognizerName) + .recognizer; } /** @@ -4061,17 +5319,20 @@ export class SpeechClient { */ close(): Promise { if (this.speechStub && !this._terminated) { - return this.speechStub.then(stub => { + return this.speechStub.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(); } } + import {ImprovedStreamingClient} from '../helpers'; // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface SpeechClient extends ImprovedStreamingClient {} diff --git a/packages/google-cloud-speech/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-speech/system-test/fixtures/sample/src/index.ts index 4c716fc7b0d6..785fad9f0eb1 100644 --- a/packages/google-cloud-speech/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-speech/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 {AdaptationClient, SpeechClient} from '@google-cloud/speech'; +import { AdaptationClient, SpeechClient } from '@google-cloud/speech'; // check that the client class type name can be used function doStuffWithAdaptationClient(client: AdaptationClient) { diff --git a/packages/google-cloud-speech/system-test/install.ts b/packages/google-cloud-speech/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-speech/system-test/install.ts +++ b/packages/google-cloud-speech/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-speech/test/gapic_adaptation_v1.ts b/packages/google-cloud-speech/test/gapic_adaptation_v1.ts index 266efe302b15..8aa639a39fe8 100644 --- a/packages/google-cloud-speech/test/gapic_adaptation_v1.ts +++ b/packages/google-cloud-speech/test/gapic_adaptation_v1.ts @@ -19,1768 +19,2182 @@ 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 adaptationModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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.AdaptationClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new adaptationModule.v1.AdaptationClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new adaptationModule.v1.AdaptationClient(); - 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 = adaptationModule.v1.AdaptationClient.servicePath; - assert.strictEqual(servicePath, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = adaptationModule.v1.AdaptationClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new adaptationModule.v1.AdaptationClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new adaptationModule.v1.AdaptationClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new adaptationModule.v1.AdaptationClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + it('has universeDomain', () => { + const client = new adaptationModule.v1.AdaptationClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.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 adaptationModule.v1.AdaptationClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1.AdaptationClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1.AdaptationClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = adaptationModule.v1.AdaptationClient.servicePath; + assert.strictEqual(servicePath, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = adaptationModule.v1.AdaptationClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new adaptationModule.v1.AdaptationClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('has port', () => { - const port = adaptationModule.v1.AdaptationClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new adaptationModule.v1.AdaptationClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('should create a client with no option', () => { - const client = new adaptationModule.v1.AdaptationClient(); - 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 adaptationModule.v1.AdaptationClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1.AdaptationClient({ - 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 adaptationModule.v1.AdaptationClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - await client.initialize(); - assert(client.adaptationStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new adaptationModule.v1.AdaptationClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.adaptationStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = adaptationModule.v1.AdaptationClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new adaptationModule.v1.AdaptationClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1.AdaptationClient({ - 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 adaptationModule.v1.AdaptationClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1.AdaptationClient({ - 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 adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + await client.initialize(); + assert(client.adaptationStub); }); - describe('createPhraseSet', () => { - it('invokes createPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.createPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.adaptationStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1.AdaptationClient({ + 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 createPhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createPhraseSet(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1.AdaptationClient({ + 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('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.createPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getPhraseSet', () => { - it('invokes getPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.createPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createPhraseSet(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPhraseSet(request), expectedError); - }); + it('invokes getPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updatePhraseSet', () => { - it('invokes updatePhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.updatePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.updatePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.PhraseSet(), + ); + client.innerApiCalls.updatePhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updatePhraseSet(request), expectedError); - }); + it('invokes updatePhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deletePhraseSet', () => { - it('invokes deletePhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.deletePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updatePhraseSet(request), expectedError); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.deletePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePhraseSet( - 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.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deletePhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + 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.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deletePhraseSet(request), expectedError); - }); + it('invokes deletePhraseSet with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deletePhraseSet(request), expectedError); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.createCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCustomClass', () => { - it('invokes createCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.createCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.createCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCustomClass(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCustomClass(request), expectedError); - }); + it('invokes getCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.getCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCustomClass', () => { - it('invokes getCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.getCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.updateCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.CustomClass(), + ); + client.innerApiCalls.updateCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCustomClass(request), expectedError); - }); + it('invokes updateCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCustomClass', () => { - it('invokes updateCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.updateCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCustomClass(request), expectedError); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + 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.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCustomClass(request), expectedError); - }); + it('invokes deleteCustomClass with closed client', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteCustomClass(request), expectedError); + }); + }); + + describe('listPhraseSet', () => { + it('invokes listPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCustomClass', () => { - it('invokes deleteCustomClass without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.IPhraseSet[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCustomClass( - 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.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listPhraseSetStream without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1.PhraseSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes deleteCustomClass with closed client', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteCustomClass(request), expectedError); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request), + ); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listPhraseSet', () => { - it('invokes listPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.listPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listPhraseSetStream with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1.PhraseSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IPhraseSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet 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.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request), + ); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPhraseSetStream without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { - 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.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSet without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), + ]; + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; + const iterable = client.listPhraseSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPhraseSetStream with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSet with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listPhraseSet without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; - const iterable = client.listPhraseSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listCustomClasses without error using callback', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.ICustomClass[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPhraseSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1.IPhraseSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.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.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCustomClasses', () => { - it('invokes listCustomClasses without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listCustomClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses without error using callback', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCustomClasses( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.ICustomClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCustomClasses with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCustomClasses with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCustomClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCustomClassesStream without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1.CustomClass) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCustomClassesStream without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { - 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.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream 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.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCustomClassesStream with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCustomClassesStream with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1.CustomClass) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listCustomClasses without error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; - const iterable = client.listCustomClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate 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.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCustomClasses with error', async () => { - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCustomClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCustomClasses without error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v1.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('customClass', async () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listCustomClasses with error', async () => { + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('customClass', async () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - 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 adaptationModule.v1.AdaptationClient({ + 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('phraseSet', async () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('phraseSet', async () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new adaptationModule.v1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new adaptationModule.v1.AdaptationClient({ - 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 adaptationModule.v1.AdaptationClient({ + 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-speech/test/gapic_adaptation_v1p1beta1.ts b/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts index 5bc91f3a67b1..a2a40e858900 100644 --- a/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts +++ b/packages/google-cloud-speech/test/gapic_adaptation_v1p1beta1.ts @@ -19,1768 +19,2235 @@ 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 adaptationModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v1p1beta1.AdaptationClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient(); - 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 = adaptationModule.v1p1beta1.AdaptationClient.servicePath; - assert.strictEqual(servicePath, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = adaptationModule.v1p1beta1.AdaptationClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + it('has universeDomain', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.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 adaptationModule.v1p1beta1.AdaptationClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1p1beta1.AdaptationClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1p1beta1.AdaptationClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + adaptationModule.v1p1beta1.AdaptationClient.servicePath; + assert.strictEqual(servicePath, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + adaptationModule.v1p1beta1.AdaptationClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('has port', () => { - const port = adaptationModule.v1p1beta1.AdaptationClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('should create a client with no option', () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient(); - 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 adaptationModule.v1p1beta1.AdaptationClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 adaptationModule.v1p1beta1.AdaptationClient({ - 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 adaptationModule.v1p1beta1.AdaptationClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - await client.initialize(); - assert(client.adaptationStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new adaptationModule.v1p1beta1.AdaptationClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.adaptationStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = adaptationModule.v1p1beta1.AdaptationClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.adaptationStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - 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 adaptationModule.v1p1beta1.AdaptationClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - 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 adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + await client.initialize(); + assert(client.adaptationStub); }); - describe('createPhraseSet', () => { - it('invokes createPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.createPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.adaptationStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.createPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.adaptationStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet 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 adaptationModule.v1p1beta1.AdaptationClient({ + 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 createPhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createPhraseSet(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + 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('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.createPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.createPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getPhraseSet', () => { - it('invokes getPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.createPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createPhraseSet(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPhraseSet(request), expectedError); - }); + it('invokes getPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updatePhraseSet', () => { - it('invokes updatePhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.updatePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.PhraseSet() - ); - client.innerApiCalls.updatePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.updatePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.updatePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updatePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ); + client.innerApiCalls.updatePhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updatePhraseSet(request), expectedError); - }); + it('invokes updatePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deletePhraseSet', () => { - it('invokes deletePhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.deletePhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updatePhraseSet(request), expectedError); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deletePhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.deletePhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deletePhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePhraseSet( - 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.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deletePhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + 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.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deletePhraseSet(request), expectedError); - }); + it('invokes deletePhraseSet with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deletePhraseSet(request), expectedError); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.createCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCustomClass', () => { - it('invokes createCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.createCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.createCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.createCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCustomClass(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCustomClass(request), expectedError); - }); + it('invokes getCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.getCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCustomClass', () => { - it('invokes getCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.getCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.updateCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ); + client.innerApiCalls.updateCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCustomClass(request), expectedError); - }); + it('invokes updateCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCustomClass', () => { - it('invokes updateCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.updateCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCustomClass(request), expectedError); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.CustomClass() - ); - client.innerApiCalls.updateCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + 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.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCustomClass(request), expectedError); - }); + it('invokes deleteCustomClass with closed client', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteCustomClass(request), expectedError); + }); + }); + + describe('listPhraseSet', () => { + it('invokes listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + ]; + client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCustomClass', () => { - it('invokes deleteCustomClass without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPhraseSet without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + ]; + client.innerApiCalls.listPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCustomClass( - 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.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listPhraseSetStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + ]; + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes deleteCustomClass with closed client', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteCustomClass(request), expectedError); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request), + ); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listPhraseSet', () => { - it('invokes listPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.listPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listPhraseSetStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listPhraseSet without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IPhraseSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.listPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSet 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.listPhraseSet.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSet, request), + ); + assert( + (client.descriptors.page.listPhraseSet.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPhraseSetStream without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { - 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.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSet without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.PhraseSet(), + ), + ]; + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + const iterable = client.listPhraseSetAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPhraseSetStream with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPhraseSetStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSet, request)); - assert( - (client.descriptors.page.listPhraseSet.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSet with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSet.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSet.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listPhraseSet without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.PhraseSet()), - ]; - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; - const iterable = client.listPhraseSetAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listCustomClasses without error using callback', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + ]; + client.innerApiCalls.listCustomClasses = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.ICustomClass[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listPhraseSet with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListPhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSet.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPhraseSetAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1p1beta1.IPhraseSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSet.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSet.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.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCustomClasses', () => { - it('invokes listCustomClasses without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listCustomClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listCustomClasses without error using callback', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCustomClasses( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.ICustomClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCustomClasses with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCustomClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCustomClassesStream without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + ]; + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCustomClassesStream without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { - 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.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream 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.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCustomClassesStream with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCustomClassesStream with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v1p1beta1.CustomClass[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v1p1beta1.CustomClass) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listCustomClasses without error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v1p1beta1.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; - const iterable = client.listCustomClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate 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.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCustomClasses with error', async () => { - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCustomClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCustomClasses without error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.CustomClass(), + ), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('customClass', async () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listCustomClasses with error', async () => { + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v1p1beta1.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v1p1beta1.ICustomClass[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('customClass', async () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - 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 adaptationModule.v1p1beta1.AdaptationClient({ + 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('phraseSet', async () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('phraseSet', async () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new adaptationModule.v1p1beta1.AdaptationClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new adaptationModule.v1p1beta1.AdaptationClient({ - 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 adaptationModule.v1p1beta1.AdaptationClient({ + 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-speech/test/gapic_speech_v1.ts b/packages/google-cloud-speech/test/gapic_speech_v1.ts index 0811fb43ba57..66e97b4210cb 100644 --- a/packages/google-cloud-speech/test/gapic_speech_v1.ts +++ b/packages/google-cloud-speech/test/gapic_speech_v1.ts @@ -19,846 +19,1062 @@ 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 speechModule 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 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 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 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.SpeechClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new speechModule.v1.SpeechClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new speechModule.v1.SpeechClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new speechModule.v1.SpeechClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new speechModule.v1.SpeechClient(); + 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 = speechModule.v1.SpeechClient.servicePath; - assert.strictEqual(servicePath, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = speechModule.v1.SpeechClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new speechModule.v1.SpeechClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 = speechModule.v1.SpeechClient.servicePath; + assert.strictEqual(servicePath, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new speechModule.v1.SpeechClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = speechModule.v1.SpeechClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new speechModule.v1.SpeechClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 speechModule.v1.SpeechClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v1.SpeechClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v1.SpeechClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new speechModule.v1.SpeechClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('has port', () => { - const port = speechModule.v1.SpeechClient.port; - assert(port); - assert(typeof port === 'number'); + 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 speechModule.v1.SpeechClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 no option', () => { - const client = new speechModule.v1.SpeechClient(); - 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 speechModule.v1.SpeechClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.configured.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 speechModule.v1.SpeechClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new speechModule.v1.SpeechClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - await client.initialize(); - assert(client.speechStub); - }); + it('has port', () => { + const port = speechModule.v1.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.speechStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new speechModule.v1.SpeechClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new speechModule.v1.SpeechClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1.SpeechClient({ - 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 initialize method and supports deferred initialization', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1.SpeechClient({ - 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 initialized client', (done) => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.speechStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('recognize', () => { - it('invokes recognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); - const [response] = await client.recognize(request); - assert.deepStrictEqual(response, expectedResponse); + it('has close method for the non-initialized client', (done) => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes recognize without error using callback', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recognize( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1.IRecognizeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1.SpeechClient({ + 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 recognize with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recognize(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1.SpeechClient({ + 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 recognize with closed client', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.RecognizeRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.recognize(request), expectedError); - }); + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeResponse(), + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('longRunningRecognize', () => { - it('invokes longRunningRecognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); - const [operation] = await client.longRunningRecognize(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeResponse(), + ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1.IRecognizeResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes longRunningRecognize without error using callback', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.longRunningRecognize( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes recognize with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + }); - it('invokes longRunningRecognize with call error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.longRunningRecognize(request), expectedError); - }); + it('invokes recognize with closed client', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.RecognizeRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.recognize(request), expectedError); + }); + }); - it('invokes longRunningRecognize with LRO error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.longRunningRecognize(request); - await assert.rejects(operation.promise(), expectedError); - }); + describe('longRunningRecognize', () => { + it('invokes longRunningRecognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCall(expectedResponse); + const [operation] = await client.longRunningRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes checkLongRunningRecognizeProgress without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes longRunningRecognize without error using callback', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.longRunningRecognize( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1.ILongRunningRecognizeMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes checkLongRunningRecognizeProgress with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes longRunningRecognize with call error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.longRunningRecognize(request), expectedError); }); - describe('streamingRecognize', () => { - it('invokes streamingRecognize without error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeResponse() - ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { - 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.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes longRunningRecognize with LRO error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.LongRunningRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.longRunningRecognize(request); + await assert.rejects(operation.promise(), expectedError); + }); - it('invokes streamingRecognize with error', async () => { - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1.StreamingRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes checkLongRunningRecognizeProgress without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLongRunningRecognizeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 checkLongRunningRecognizeProgress with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkLongRunningRecognizeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeRequest(), + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeResponse(), + ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v1.StreamingRecognizeResponse, + ) => { + 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.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 streamingRecognize with error', async () => { + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1.StreamingRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( + undefined, + expectedError, + ); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v1.StreamingRecognizeResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ - 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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 speechModule.v1.SpeechClient({ + 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('customClass', async () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('Path templates', () => { + describe('customClass', async () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('phraseSet', async () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new speechModule.v1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('phraseSet', async () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new speechModule.v1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts b/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts index cf8730380a27..52d8d8c5c9e9 100644 --- a/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts +++ b/packages/google-cloud-speech/test/gapic_speech_v1p1beta1.ts @@ -19,846 +19,1062 @@ 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 speechModule 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 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 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 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('v1p1beta1.SpeechClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new speechModule.v1p1beta1.SpeechClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new speechModule.v1p1beta1.SpeechClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new speechModule.v1p1beta1.SpeechClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new speechModule.v1p1beta1.SpeechClient(); + 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 = speechModule.v1p1beta1.SpeechClient.servicePath; - assert.strictEqual(servicePath, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = speechModule.v1p1beta1.SpeechClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new speechModule.v1p1beta1.SpeechClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 = speechModule.v1p1beta1.SpeechClient.servicePath; + assert.strictEqual(servicePath, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new speechModule.v1p1beta1.SpeechClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = speechModule.v1p1beta1.SpeechClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 speechModule.v1p1beta1.SpeechClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v1p1beta1.SpeechClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v1p1beta1.SpeechClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('has port', () => { - const port = speechModule.v1p1beta1.SpeechClient.port; - assert(port); - assert(typeof port === 'number'); + 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 speechModule.v1p1beta1.SpeechClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 no option', () => { - const client = new speechModule.v1p1beta1.SpeechClient(); - 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 speechModule.v1p1beta1.SpeechClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.configured.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 speechModule.v1p1beta1.SpeechClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new speechModule.v1p1beta1.SpeechClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - await client.initialize(); - assert(client.speechStub); - }); + it('has port', () => { + const port = speechModule.v1p1beta1.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.speechStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new speechModule.v1p1beta1.SpeechClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 initialize method and supports deferred initialization', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 initialized client', (done) => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.speechStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('recognize', () => { - it('invokes recognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); - const [response] = await client.recognize(request); - assert.deepStrictEqual(response, expectedResponse); + it('has close method for the non-initialized client', (done) => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes recognize without error using callback', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recognize( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v1p1beta1.IRecognizeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1p1beta1.SpeechClient({ + 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 recognize with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recognize(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new speechModule.v1p1beta1.SpeechClient({ + 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 recognize with closed client', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.RecognizeRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.recognize(request), expectedError); - }); + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeResponse(), + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('longRunningRecognize', () => { - it('invokes longRunningRecognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(expectedResponse); - const [operation] = await client.longRunningRecognize(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeResponse(), + ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v1p1beta1.IRecognizeResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes longRunningRecognize without error using callback', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.longRunningRecognize = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.longRunningRecognize( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes recognize with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + }); - it('invokes longRunningRecognize with call error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.longRunningRecognize(request), expectedError); - }); + it('invokes recognize with closed client', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.RecognizeRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.recognize(request), expectedError); + }); + }); - it('invokes longRunningRecognize with LRO error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.longRunningRecognize = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.longRunningRecognize(request); - await assert.rejects(operation.promise(), expectedError); - }); + describe('longRunningRecognize', () => { + it('invokes longRunningRecognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCall(expectedResponse); + const [operation] = await client.longRunningRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes checkLongRunningRecognizeProgress without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLongRunningRecognizeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes longRunningRecognize without error using callback', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.longRunningRecognize = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.longRunningRecognize( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeResponse, + protos.google.cloud.speech.v1p1beta1.ILongRunningRecognizeMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes checkLongRunningRecognizeProgress with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLongRunningRecognizeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes longRunningRecognize with call error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.longRunningRecognize(request), expectedError); }); - describe('streamingRecognize', () => { - it('invokes streamingRecognize without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse() - ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { - 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.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes longRunningRecognize with LRO error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.LongRunningRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.longRunningRecognize = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.longRunningRecognize(request); + await assert.rejects(operation.promise(), expectedError); + }); - it('invokes streamingRecognize with error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes checkLongRunningRecognizeProgress without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLongRunningRecognizeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 checkLongRunningRecognizeProgress with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkLongRunningRecognizeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest(), + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse(), + ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse, + ) => { + 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.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 streamingRecognize with error', async () => { + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v1p1beta1.StreamingRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( + undefined, + expectedError, + ); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v1p1beta1.StreamingRecognizeResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ - 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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 speechModule.v1p1beta1.SpeechClient({ + 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('customClass', async () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('Path templates', () => { + describe('customClass', async () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('phraseSet', async () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new speechModule.v1p1beta1.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('phraseSet', async () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new speechModule.v1p1beta1.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-speech/test/gapic_speech_v2.ts b/packages/google-cloud-speech/test/gapic_speech_v2.ts index 174a2042ce0d..3b4f2134950d 100644 --- a/packages/google-cloud-speech/test/gapic_speech_v2.ts +++ b/packages/google-cloud-speech/test/gapic_speech_v2.ts @@ -19,4517 +19,5678 @@ 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 speechModule 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 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 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.SpeechClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new speechModule.v2.SpeechClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new speechModule.v2.SpeechClient(); - 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 = speechModule.v2.SpeechClient.servicePath; - assert.strictEqual(servicePath, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = speechModule.v2.SpeechClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new speechModule.v2.SpeechClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new speechModule.v2.SpeechClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v2.SpeechClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v2.SpeechClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'speech.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 speechModule.v2.SpeechClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = speechModule.v2.SpeechClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new speechModule.v2.SpeechClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new speechModule.v2.SpeechClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - await client.initialize(); - assert(client.speechStub); - }); - - it('has close method for the initialized client', done => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.speechStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.speechStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); }); - describe('getRecognizer', () => { - it('invokes getRecognizer without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Recognizer() - ); - client.innerApiCalls.getRecognizer = stubSimpleCall(expectedResponse); - const [response] = await client.getRecognizer(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecognizer without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Recognizer() - ); - client.innerApiCalls.getRecognizer = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getRecognizer( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IRecognizer|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecognizer with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getRecognizer = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getRecognizer(request), expectedError); - const actualRequest = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getRecognizer with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getRecognizer(request), expectedError); - }); + it('has universeDomain', () => { + const client = new speechModule.v2.SpeechClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('recognize', () => { - it('invokes recognize without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.RecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); - const [response] = await client.recognize(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recognize without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.RecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeResponse() - ); - client.innerApiCalls.recognize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.recognize( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IRecognizeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recognize with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.RecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.recognize(request), expectedError); - const actualRequest = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.recognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes recognize with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.RecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.RecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.recognize(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 = speechModule.v2.SpeechClient.servicePath; + assert.strictEqual(servicePath, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = speechModule.v2.SpeechClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'speech.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new speechModule.v2.SpeechClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); }); - describe('getConfig', () => { - it('invokes getConfig without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Config() - ); - client.innerApiCalls.getConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getConfig without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Config() - ); - client.innerApiCalls.getConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConfig( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfig 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 speechModule.v2.SpeechClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.example.com'); + }); - it('invokes getConfig with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConfig 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 speechModule.v2.SpeechClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 speechModule.v2.SpeechClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'speech.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 speechModule.v2.SpeechClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getConfig with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConfig(request), expectedError); - }); + it('has port', () => { + const port = speechModule.v2.SpeechClient.port; + assert(port); + assert(typeof port === 'number'); }); - describe('updateConfig', () => { - it('invokes updateConfig without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateConfigRequest() - ); - request.config ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateConfigRequest', ['config', 'name']); - request.config.name = defaultValue1; - const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Config() - ); - client.innerApiCalls.updateConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfig 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 speechModule.v2.SpeechClient(); + assert(client); + }); - it('invokes updateConfig without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateConfigRequest() - ); - request.config ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateConfigRequest', ['config', 'name']); - request.config.name = defaultValue1; - const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.Config() - ); - client.innerApiCalls.updateConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateConfig( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfig 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 speechModule.v2.SpeechClient({ + fallback: true, + }); + assert(client); + }); - it('invokes updateConfig with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateConfigRequest() - ); - request.config ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateConfigRequest', ['config', 'name']); - request.config.name = defaultValue1; - const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateConfig 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 speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + await client.initialize(); + assert(client.speechStub); + }); - it('invokes updateConfig with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateConfigRequest() - ); - request.config ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateConfigRequest', ['config', 'name']); - request.config.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateConfig(request), expectedError); + it('has close method for the initialized client', (done) => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.speechStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCustomClass', () => { - it('invokes getCustomClass without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); - const [response] = await client.getCustomClass(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass 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 speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.speechStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCustomClass without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.CustomClass() - ); - client.innerApiCalls.getCustomClass = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCustomClass( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.ICustomClass|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass 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 speechModule.v2.SpeechClient({ + 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 getCustomClass with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCustomClass = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.getCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCustomClass 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 speechModule.v2.SpeechClient({ + 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('getRecognizer', () => { + it('invokes getRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Recognizer(), + ); + client.innerApiCalls.getRecognizer = stubSimpleCall(expectedResponse); + const [response] = await client.getRecognizer(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCustomClass with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCustomClass(request), expectedError); - }); + it('invokes getRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Recognizer(), + ); + client.innerApiCalls.getRecognizer = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getRecognizer( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizer | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getPhraseSet', () => { - it('invokes getPhraseSet without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); - const [response] = await client.getPhraseSet(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRecognizer with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getRecognizer = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.PhraseSet() - ); - client.innerApiCalls.getPhraseSet = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getPhraseSet( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IPhraseSet|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getRecognizer with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getRecognizer(request), expectedError); + }); + }); + + describe('recognize', () => { + it('invokes recognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeResponse(), + ); + client.innerApiCalls.recognize = stubSimpleCall(expectedResponse); + const [response] = await client.recognize(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getPhraseSet = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes recognize without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeResponse(), + ); + client.innerApiCalls.recognize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.recognize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizeResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getPhraseSet with closed client', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.GetPhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.GetPhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getPhraseSet(request), expectedError); - }); + it('invokes recognize with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.recognize = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.recognize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.recognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createRecognizer', () => { - it('invokes createRecognizer without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateRecognizerRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRecognizer = stubLongRunningCall(expectedResponse); - const [operation] = await client.createRecognizer(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes recognize with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.RecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.RecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.recognize(request), expectedError); + }); + }); + + describe('getConfig', () => { + it('invokes getConfig without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config(), + ); + client.innerApiCalls.getConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createRecognizer without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateRecognizerRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createRecognizer = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createRecognizer( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfig without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config(), + ); + client.innerApiCalls.getConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createRecognizer with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateRecognizerRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRecognizer = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createRecognizer(request), expectedError); - const actualRequest = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfig with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createRecognizer with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateRecognizerRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createRecognizer = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createRecognizer(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConfig with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConfig(request), expectedError); + }); + }); + + describe('updateConfig', () => { + it('invokes updateConfig without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest(), + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'], + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config(), + ); + client.innerApiCalls.updateConfig = stubSimpleCall(expectedResponse); + const [response] = await client.updateConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateRecognizerProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateRecognizerProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateConfig without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest(), + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'], + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.Config(), + ); + client.innerApiCalls.updateConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateRecognizerProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateRecognizerProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateConfig with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest(), + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'], + ); + request.config.name = defaultValue1; + const expectedHeaderRequestParams = `config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateRecognizer', () => { - it('invokes updateRecognizer without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateRecognizerRequest() - ); - request.recognizer ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateRecognizerRequest', ['recognizer', 'name']); - request.recognizer.name = defaultValue1; - const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRecognizer = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateRecognizer(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateConfig with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateConfigRequest(), + ); + request.config ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateConfigRequest', + ['config', 'name'], + ); + request.config.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateConfig(request), expectedError); + }); + }); + + describe('getCustomClass', () => { + it('invokes getCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.CustomClass(), + ); + client.innerApiCalls.getCustomClass = stubSimpleCall(expectedResponse); + const [response] = await client.getCustomClass(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateRecognizer without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateRecognizerRequest() - ); - request.recognizer ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateRecognizerRequest', ['recognizer', 'name']); - request.recognizer.name = defaultValue1; - const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateRecognizer = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateRecognizer( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.CustomClass(), + ); + client.innerApiCalls.getCustomClass = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCustomClass( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.ICustomClass | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateRecognizer with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateRecognizerRequest() - ); - request.recognizer ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateRecognizerRequest', ['recognizer', 'name']); - request.recognizer.name = defaultValue1; - const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRecognizer = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateRecognizer(request), expectedError); - const actualRequest = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCustomClass = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateRecognizer with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateRecognizerRequest() - ); - request.recognizer ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateRecognizerRequest', ['recognizer', 'name']); - request.recognizer.name = defaultValue1; - const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateRecognizer = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateRecognizer(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCustomClass with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCustomClass(request), expectedError); + }); + }); + + describe('getPhraseSet', () => { + it('invokes getPhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = stubSimpleCall(expectedResponse); + const [response] = await client.getPhraseSet(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateRecognizerProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateRecognizerProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getPhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.PhraseSet(), + ); + client.innerApiCalls.getPhraseSet = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getPhraseSet( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IPhraseSet | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateRecognizerProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateRecognizerProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes getPhraseSet with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getPhraseSet = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteRecognizer', () => { - it('invokes deleteRecognizer without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRecognizer = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteRecognizer(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getPhraseSet with closed client', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.GetPhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.GetPhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getPhraseSet(request), expectedError); + }); + }); + + describe('createRecognizer', () => { + it('invokes createRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteRecognizer without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteRecognizer = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteRecognizer( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteRecognizer with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRecognizer = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteRecognizer(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRecognizer = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteRecognizer with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteRecognizer = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteRecognizer(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateRecognizerRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteRecognizerProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteRecognizerProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCreateRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateRecognizerProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteRecognizerProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteRecognizerProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateRecognizerProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateRecognizer', () => { + it('invokes updateRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest(), + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'], + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('undeleteRecognizer', () => { - it('invokes undeleteRecognizer without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteRecognizer = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteRecognizer(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest(), + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'], + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteRecognizer without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteRecognizer = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteRecognizer( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest(), + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'], + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecognizer = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteRecognizer with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteRecognizer = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteRecognizer(request), expectedError); - const actualRequest = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateRecognizerRequest(), + ); + request.recognizer ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateRecognizerRequest', + ['recognizer', 'name'], + ); + request.recognizer.name = defaultValue1; + const expectedHeaderRequestParams = `recognizer.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteRecognizer with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteRecognizerRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteRecognizerRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteRecognizer = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteRecognizer(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteRecognizer as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateRecognizerProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUndeleteRecognizerProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeleteRecognizerProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateRecognizerProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteRecognizer', () => { + it('invokes deleteRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUndeleteRecognizerProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeleteRecognizerProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes deleteRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchRecognize', () => { - it('invokes batchRecognize without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.BatchRecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.BatchRecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchRecognize = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchRecognize(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRecognizer = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchRecognize without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.BatchRecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.BatchRecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchRecognize = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchRecognize( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchRecognize with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.BatchRecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.BatchRecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchRecognize = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchRecognize(request), expectedError); - const actualRequest = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteRecognizerProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes batchRecognize with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.BatchRecognizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.BatchRecognizeRequest', ['recognizer']); - request.recognizer = defaultValue1; - const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchRecognize = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchRecognize(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchRecognize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteRecognizerProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeleteRecognizer', () => { + it('invokes undeleteRecognizer without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeleteRecognizer = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteRecognizer(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchRecognizeProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchRecognizeProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes undeleteRecognizer without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeleteRecognizer = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteRecognizer( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IRecognizer, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchRecognizeProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchRecognizeProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes undeleteRecognizer with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteRecognizer = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.undeleteRecognizer(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCustomClass', () => { - it('invokes createCustomClass without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCustomClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCustomClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeleteRecognizer with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteRecognizerRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteRecognizerRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteRecognizer = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.undeleteRecognizer(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteRecognizer as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createCustomClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCustomClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUndeleteRecognizerProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteRecognizerProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createCustomClass with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUndeleteRecognizerProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUndeleteRecognizerProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('batchRecognize', () => { + it('invokes batchRecognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchRecognize = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchRecognize(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCustomClass with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreateCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreateCustomClassRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCustomClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCustomClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchRecognize without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchRecognize = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchRecognize( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IBatchRecognizeResponse, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCustomClassProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateCustomClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchRecognize with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRecognize = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchRecognize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateCustomClassProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateCustomClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes batchRecognize with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.BatchRecognizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.BatchRecognizeRequest', + ['recognizer'], + ); + request.recognizer = defaultValue1; + const expectedHeaderRequestParams = `recognizer=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchRecognize = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchRecognize(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchRecognize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCustomClass', () => { - it('invokes updateCustomClass without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCustomClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCustomClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchRecognizeProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchRecognizeProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateCustomClass without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateCustomClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCustomClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchRecognizeProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchRecognizeProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createCustomClass', () => { + it('invokes createCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCustomClass with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdateCustomClassRequest() - ); - request.customClass ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdateCustomClassRequest', ['customClass', 'name']); - request.customClass.name = defaultValue1; - const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCustomClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCustomClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateCustomClassProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateCustomClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreateCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreateCustomClassRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateCustomClassProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateCustomClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkCreateCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateCustomClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('deleteCustomClass', () => { - it('invokes deleteCustomClass without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCustomClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteCustomClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateCustomClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCustomClass', () => { + it('invokes updateCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteCustomClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCustomClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCustomClass with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCustomClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteCustomClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdateCustomClassRequest(), + ); + request.customClass ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdateCustomClassRequest', + ['customClass', 'name'], + ); + request.customClass.name = defaultValue1; + const expectedHeaderRequestParams = `custom_class.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteCustomClassProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteCustomClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUpdateCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateCustomClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkDeleteCustomClassProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteCustomClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUpdateCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateCustomClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteCustomClass', () => { + it('invokes deleteCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('undeleteCustomClass', () => { - it('invokes undeleteCustomClass without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteCustomClass = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteCustomClass(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteCustomClass without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeleteCustomClass = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteCustomClass( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteCustomClass with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteCustomClass = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteCustomClass(request), expectedError); - const actualRequest = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeleteCustomClass with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeleteCustomClassRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeleteCustomClassRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteCustomClass = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteCustomClass(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeleteCustomClass as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteCustomClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUndeleteCustomClassProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeleteCustomClassProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkDeleteCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteCustomClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeleteCustomClass', () => { + it('invokes undeleteCustomClass without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeleteCustomClass = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteCustomClass(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUndeleteCustomClassProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeleteCustomClassProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes undeleteCustomClass without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeleteCustomClass = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteCustomClass( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.ICustomClass, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createPhraseSet', () => { - it('invokes createPhraseSet without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPhraseSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.createPhraseSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeleteCustomClass with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteCustomClass = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.undeleteCustomClass(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPhraseSet without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createPhraseSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createPhraseSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeleteCustomClass with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeleteCustomClassRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeleteCustomClassRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteCustomClass = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.undeleteCustomClass(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeleteCustomClass as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createPhraseSet with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createPhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUndeleteCustomClassProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteCustomClassProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes createPhraseSet with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.CreatePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.CreatePhraseSetRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createPhraseSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createPhraseSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createPhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUndeleteCustomClassProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUndeleteCustomClassProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createPhraseSet', () => { + it('invokes createPhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createPhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePhraseSetProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreatePhraseSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createPhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createPhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createPhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreatePhraseSetProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreatePhraseSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createPhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createPhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updatePhraseSet', () => { - it('invokes updatePhraseSet without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updatePhraseSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.updatePhraseSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createPhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.CreatePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.CreatePhraseSetRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createPhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createPhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createPhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updatePhraseSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updatePhraseSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreatePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreatePhraseSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updatePhraseSet with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updatePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreatePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreatePhraseSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updatePhraseSet', () => { + it('invokes updatePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updatePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updatePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updatePhraseSet with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UpdatePhraseSetRequest() - ); - request.phraseSet ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UpdatePhraseSetRequest', ['phraseSet', 'name']); - request.phraseSet.name = defaultValue1; - const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updatePhraseSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updatePhraseSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updatePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updatePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updatePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updatePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdatePhraseSetProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdatePhraseSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updatePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updatePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdatePhraseSetProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdatePhraseSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updatePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UpdatePhraseSetRequest(), + ); + request.phraseSet ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UpdatePhraseSetRequest', + ['phraseSet', 'name'], + ); + request.phraseSet.name = defaultValue1; + const expectedHeaderRequestParams = `phrase_set.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updatePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updatePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updatePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deletePhraseSet', () => { - it('invokes deletePhraseSet without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePhraseSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.deletePhraseSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdatePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdatePhraseSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deletePhraseSet without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deletePhraseSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deletePhraseSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdatePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdatePhraseSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deletePhraseSet', () => { + it('invokes deletePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deletePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deletePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deletePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deletePhraseSet with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.DeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.DeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deletePhraseSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deletePhraseSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deletePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeletePhraseSetProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeletePhraseSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deletePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.DeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.DeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deletePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deletePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeletePhraseSetProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeletePhraseSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeletePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeletePhraseSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('undeletePhraseSet', () => { - it('invokes undeletePhraseSet without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeletePhraseSet = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeletePhraseSet(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeletePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeletePhraseSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeletePhraseSet', () => { + it('invokes undeletePhraseSet without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeletePhraseSet = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeletePhraseSet(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeletePhraseSet without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.undeletePhraseSet = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeletePhraseSet( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeletePhraseSet without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.undeletePhraseSet = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeletePhraseSet( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.speech.v2.IPhraseSet, + protos.google.cloud.speech.v2.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeletePhraseSet with call error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeletePhraseSet = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeletePhraseSet(request), expectedError); - const actualRequest = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeletePhraseSet with call error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeletePhraseSet = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.undeletePhraseSet(request), expectedError); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes undeletePhraseSet with LRO error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.UndeletePhraseSetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.UndeletePhraseSetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.undeletePhraseSet = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeletePhraseSet(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.undeletePhraseSet as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes undeletePhraseSet with LRO error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.UndeletePhraseSetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.UndeletePhraseSetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.undeletePhraseSet = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.undeletePhraseSet(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.undeletePhraseSet as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUndeletePhraseSetProgress without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeletePhraseSetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUndeletePhraseSetProgress without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeletePhraseSetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUndeletePhraseSetProgress with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeletePhraseSetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUndeletePhraseSetProgress with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUndeletePhraseSetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('streamingRecognize', () => { + it('invokes streamingRecognize without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeRequest(), + ); + + const expectedResponse = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeResponse(), + ); + client.innerApiCalls.streamingRecognize = + stubBidiStreamingCall(expectedResponse); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v2.StreamingRecognizeResponse, + ) => { + 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.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); }); - describe('streamingRecognize', () => { - it('invokes streamingRecognize without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.StreamingRecognizeRequest() - ); - - const expectedResponse = generateSampleMessage( - new protos.google.cloud.speech.v2.StreamingRecognizeResponse() - ); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(expectedResponse); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v2.StreamingRecognizeResponse) => { - 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.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes streamingRecognize with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.StreamingRecognizeRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.streamingRecognize = stubBidiStreamingCall( + undefined, + expectedError, + ); + const stream = client._streamingRecognize(); + const promise = new Promise((resolve, reject) => { + stream.on( + 'data', + ( + response: protos.google.cloud.speech.v2.StreamingRecognizeResponse, + ) => { + resolve(response); + }, + ); + stream.on('error', (err: Error) => { + reject(err); + }); + stream.write(request); + stream.end(); + }); + await assert.rejects(promise, expectedError); + assert( + (client.innerApiCalls.streamingRecognize as SinonStub) + .getCall(0) + .calledWith(null), + ); + assert.deepStrictEqual( + ((stream as unknown as PassThrough)._transform as SinonStub).getCall(0) + .args[0], + request, + ); + }); + }); + + describe('listRecognizers', () => { + it('invokes listRecognizers without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.innerApiCalls.listRecognizers = stubSimpleCall(expectedResponse); + const [response] = await client.listRecognizers(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes streamingRecognize with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.StreamingRecognizeRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.streamingRecognize = stubBidiStreamingCall(undefined, expectedError); - const stream = client._streamingRecognize(); - const promise = new Promise((resolve, reject) => { - stream.on('data', (response: protos.google.cloud.speech.v2.StreamingRecognizeResponse) => { - resolve(response); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - stream.write(request); - stream.end(); - }); - await assert.rejects(promise, expectedError); - assert((client.innerApiCalls.streamingRecognize as SinonStub) - .getCall(0).calledWith(null)); - assert.deepStrictEqual(((stream as unknown as PassThrough) - ._transform as SinonStub).getCall(0).args[0], request); - }); + it('invokes listRecognizers without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.innerApiCalls.listRecognizers = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listRecognizers( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IRecognizer[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listRecognizers', () => { - it('invokes listRecognizers without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - ]; - client.innerApiCalls.listRecognizers = stubSimpleCall(expectedResponse); - const [response] = await client.listRecognizers(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRecognizers with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listRecognizers = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listRecognizers(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listRecognizers as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listRecognizers without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - ]; - client.innerApiCalls.listRecognizers = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listRecognizers( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IRecognizer[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRecognizersStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.descriptors.page.listRecognizers.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listRecognizersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.Recognizer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.Recognizer) => { + 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.listRecognizers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRecognizers, request), + ); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRecognizers with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listRecognizers = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listRecognizers(request), expectedError); - const actualRequest = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listRecognizers as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listRecognizersStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecognizers.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listRecognizersStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.Recognizer[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.Recognizer) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listRecognizers, request), + ); + assert( + (client.descriptors.page.listRecognizers.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRecognizersStream without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - ]; - client.descriptors.page.listRecognizers.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listRecognizersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.Recognizer[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.Recognizer) => { - 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.listRecognizers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecognizers, request)); - assert( - (client.descriptors.page.listRecognizers.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRecognizers without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), + ]; + client.descriptors.page.listRecognizers.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; + const iterable = client.listRecognizersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listRecognizers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listRecognizersStream with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecognizers.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listRecognizersStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.Recognizer[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.Recognizer) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listRecognizers.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listRecognizers, request)); - assert( - (client.descriptors.page.listRecognizers.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listRecognizers with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListRecognizersRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListRecognizersRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listRecognizers.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRecognizersAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listRecognizers.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listCustomClasses', () => { + it('invokes listCustomClasses without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); + const [response] = await client.listCustomClasses(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listRecognizers without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - generateSampleMessage(new protos.google.cloud.speech.v2.Recognizer()), - ]; - client.descriptors.page.listRecognizers.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; - const iterable = client.listRecognizersAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listCustomClasses without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.innerApiCalls.listCustomClasses = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCustomClasses( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.ICustomClass[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listRecognizers with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListRecognizersRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListRecognizersRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listRecognizers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listRecognizersAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v2.IRecognizer[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listRecognizers.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listRecognizers.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.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCustomClasses', () => { - it('invokes listCustomClasses without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCall(expectedResponse); - const [response] = await client.listCustomClasses(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCustomClasses with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCustomClasses = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCustomClasses(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCustomClasses as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCustomClasses without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - ]; - client.innerApiCalls.listCustomClasses = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCustomClasses( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.ICustomClass[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCustomClassesStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.CustomClass) => { + 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.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCustomClasses with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCustomClasses = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCustomClasses(request), expectedError); - const actualRequest = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCustomClasses as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCustomClassesStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCustomClassesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.CustomClass[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.CustomClass) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCustomClasses, request), + ); + assert( + (client.descriptors.page.listCustomClasses.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCustomClassesStream without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.CustomClass) => { - 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.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCustomClasses without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), + ]; + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; + const iterable = client.listCustomClassesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCustomClassesStream with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCustomClassesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.CustomClass[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.CustomClass) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCustomClasses, request)); - assert( - (client.descriptors.page.listCustomClasses.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCustomClasses with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListCustomClassesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListCustomClassesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCustomClasses.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCustomClassesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCustomClasses.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listPhraseSets', () => { + it('invokes listPhraseSets without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSets = stubSimpleCall(expectedResponse); + const [response] = await client.listPhraseSets(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCustomClasses without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - generateSampleMessage(new protos.google.cloud.speech.v2.CustomClass()), - ]; - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; - const iterable = client.listCustomClassesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listPhraseSets without error using callback', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.innerApiCalls.listPhraseSets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listPhraseSets( + request, + ( + err?: Error | null, + result?: protos.google.cloud.speech.v2.IPhraseSet[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listCustomClasses with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListCustomClassesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListCustomClassesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCustomClasses.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCustomClassesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v2.ICustomClass[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCustomClasses.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCustomClasses.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.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listPhraseSets', () => { - it('invokes listPhraseSets without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSets = stubSimpleCall(expectedResponse); - const [response] = await client.listPhraseSets(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSets without error using callback', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - ]; - client.innerApiCalls.listPhraseSets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listPhraseSets( - request, - (err?: Error|null, result?: protos.google.cloud.speech.v2.IPhraseSet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listPhraseSets with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listPhraseSets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listPhraseSets(request), expectedError); - const actualRequest = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listPhraseSets as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listPhraseSets with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listPhraseSets = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listPhraseSets(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listPhraseSets as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listPhraseSetsStream without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - ]; - client.descriptors.page.listPhraseSets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listPhraseSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.PhraseSet) => { - 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.listPhraseSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSets, request)); - assert( - (client.descriptors.page.listPhraseSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listPhraseSetsStream without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.descriptors.page.listPhraseSets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listPhraseSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.PhraseSet) => { + 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.listPhraseSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSets, request), + ); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listPhraseSetsStream with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listPhraseSetsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; - stream.on('data', (response: protos.google.cloud.speech.v2.PhraseSet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listPhraseSets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listPhraseSets, request)); - assert( - (client.descriptors.page.listPhraseSets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listPhraseSetsStream with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listPhraseSetsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.speech.v2.PhraseSet[] = []; + stream.on( + 'data', + (response: protos.google.cloud.speech.v2.PhraseSet) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listPhraseSets, request), + ); + assert( + (client.descriptors.page.listPhraseSets.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listPhraseSets without error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), - ]; - client.descriptors.page.listPhraseSets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; - const iterable = client.listPhraseSetsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSets without error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + generateSampleMessage(new protos.google.cloud.speech.v2.PhraseSet()), + ]; + client.descriptors.page.listPhraseSets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; + const iterable = client.listPhraseSetsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listPhraseSets with error', async () => { - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.speech.v2.ListPhraseSetsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.speech.v2.ListPhraseSetsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listPhraseSets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listPhraseSetsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listPhraseSets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listPhraseSets with error', async () => { + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.speech.v2.ListPhraseSetsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.speech.v2.ListPhraseSetsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listPhraseSets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listPhraseSetsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.speech.v2.IPhraseSet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listPhraseSets.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listPhraseSets.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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ + 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('config', async () => { + const fakePath = '/rendered/path/config'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.configPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.configPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('configPath', () => { + const result = client.configPath('projectValue', 'locationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.configPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromConfigName', () => { + const result = client.matchProjectFromConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.configPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromConfigName', () => { + const result = client.matchLocationFromConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.configPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('config', async () => { - const fakePath = "/rendered/path/config"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.configPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.configPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('configPath', () => { - const result = client.configPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.configPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromConfigName', () => { - const result = client.matchProjectFromConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.configPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromConfigName', () => { - const result = client.matchLocationFromConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.configPathTemplate.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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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 speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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('customClass', async () => { - const fakePath = "/rendered/path/customClass"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - custom_class: "customClassValue", - }; - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.customClassPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.customClassPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('customClassPath', () => { - const result = client.customClassPath("projectValue", "locationValue", "customClassValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.customClassPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCustomClassName', () => { - const result = client.matchProjectFromCustomClassName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromCustomClassName', () => { - const result = client.matchLocationFromCustomClassName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCustomClassFromCustomClassName', () => { - const result = client.matchCustomClassFromCustomClassName(fakePath); - assert.strictEqual(result, "customClassValue"); - assert((client.pathTemplates.customClassPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('customClass', async () => { + const fakePath = '/rendered/path/customClass'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + custom_class: 'customClassValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.customClassPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.customClassPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('customClassPath', () => { + const result = client.customClassPath( + 'projectValue', + 'locationValue', + 'customClassValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.customClassPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCustomClassName', () => { + const result = client.matchProjectFromCustomClassName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromCustomClassName', () => { + const result = client.matchLocationFromCustomClassName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCustomClassFromCustomClassName', () => { + const result = client.matchCustomClassFromCustomClassName(fakePath); + assert.strictEqual(result, 'customClassValue'); + assert( + (client.pathTemplates.customClassPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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('phraseSet', async () => { - const fakePath = "/rendered/path/phraseSet"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - phrase_set: "phraseSetValue", - }; - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.phraseSetPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.phraseSetPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('phraseSetPath', () => { - const result = client.phraseSetPath("projectValue", "locationValue", "phraseSetValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.phraseSetPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromPhraseSetName', () => { - const result = client.matchProjectFromPhraseSetName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromPhraseSetName', () => { - const result = client.matchLocationFromPhraseSetName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchPhraseSetFromPhraseSetName', () => { - const result = client.matchPhraseSetFromPhraseSetName(fakePath); - assert.strictEqual(result, "phraseSetValue"); - assert((client.pathTemplates.phraseSetPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('phraseSet', async () => { + const fakePath = '/rendered/path/phraseSet'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + phrase_set: 'phraseSetValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.phraseSetPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.phraseSetPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('phraseSetPath', () => { + const result = client.phraseSetPath( + 'projectValue', + 'locationValue', + 'phraseSetValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.phraseSetPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromPhraseSetName', () => { + const result = client.matchProjectFromPhraseSetName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromPhraseSetName', () => { + const result = client.matchLocationFromPhraseSetName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchPhraseSetFromPhraseSetName', () => { + const result = client.matchPhraseSetFromPhraseSetName(fakePath); + assert.strictEqual(result, 'phraseSetValue'); + assert( + (client.pathTemplates.phraseSetPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new speechModule.v2.SpeechClient({ - 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 speechModule.v2.SpeechClient({ + 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('recognizer', async () => { - const fakePath = "/rendered/path/recognizer"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - recognizer: "recognizerValue", - }; - const client = new speechModule.v2.SpeechClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.recognizerPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.recognizerPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('recognizerPath', () => { - const result = client.recognizerPath("projectValue", "locationValue", "recognizerValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.recognizerPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRecognizerName', () => { - const result = client.matchProjectFromRecognizerName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.recognizerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRecognizerName', () => { - const result = client.matchLocationFromRecognizerName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.recognizerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRecognizerFromRecognizerName', () => { - const result = client.matchRecognizerFromRecognizerName(fakePath); - assert.strictEqual(result, "recognizerValue"); - assert((client.pathTemplates.recognizerPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('recognizer', async () => { + const fakePath = '/rendered/path/recognizer'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + recognizer: 'recognizerValue', + }; + const client = new speechModule.v2.SpeechClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.recognizerPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.recognizerPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('recognizerPath', () => { + const result = client.recognizerPath( + 'projectValue', + 'locationValue', + 'recognizerValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.recognizerPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromRecognizerName', () => { + const result = client.matchProjectFromRecognizerName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromRecognizerName', () => { + const result = client.matchLocationFromRecognizerName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchRecognizerFromRecognizerName', () => { + const result = client.matchRecognizerFromRecognizerName(fakePath); + assert.strictEqual(result, 'recognizerValue'); + assert( + (client.pathTemplates.recognizerPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-speech/webpack.config.js b/packages/google-cloud-speech/webpack.config.js index c880b0d7d8ec..50273cca41c0 100644 --- a/packages/google-cloud-speech/webpack.config.js +++ b/packages/google-cloud-speech/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-sql/.eslintignore b/packages/google-cloud-sql/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-sql/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-sql/.eslintrc.json b/packages/google-cloud-sql/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-sql/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-sql/README.md b/packages/google-cloud-sql/README.md index 41814fd9b839..497b95b405f9 100644 --- a/packages/google-cloud-sql/README.md +++ b/packages/google-cloud-sql/README.md @@ -241,7 +241,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-sql/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`) @@ -251,7 +251,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-sql/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-sql/protos/protos.d.ts b/packages/google-cloud-sql/protos/protos.d.ts index 550fe4464ffc..a59e3de3ed9f 100644 --- a/packages/google-cloud-sql/protos/protos.d.ts +++ b/packages/google-cloud-sql/protos/protos.d.ts @@ -55223,6 +55223,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -55240,6 +55243,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 @@ -55940,6 +55946,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -55954,6 +55963,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 @@ -56032,6 +56044,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 { @@ -56358,6 +56482,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -56372,6 +56499,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 @@ -56696,6 +56826,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, @@ -56978,6 +57211,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. */ @@ -56992,6 +57228,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 @@ -57081,6 +57320,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. */ @@ -57186,6 +57522,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -57216,6 +57553,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -57265,6 +57605,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -57399,6 +57742,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -57440,6 +57786,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 @@ -58287,6 +58636,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -58313,6 +58665,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 @@ -59247,6 +59602,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); @@ -59305,6 +59663,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[]; @@ -59525,6 +59886,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. */ @@ -59763,6 +60239,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -59785,6 +60264,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[]; @@ -60374,6 +60856,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. */ @@ -60403,6 +60891,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 @@ -60525,6 +61019,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. */ @@ -60644,8 +61248,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. */ @@ -60660,8 +61267,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. @@ -61194,6 +61804,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-sql/protos/protos.js b/packages/google-cloud-sql/protos/protos.js index e2514df66382..560fca92dccf 100644 --- a/packages/google-cloud-sql/protos/protos.js +++ b/packages/google-cloud-sql/protos/protos.js @@ -144678,6 +144678,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -144712,6 +144713,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 @@ -144744,6 +144753,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; }; @@ -144795,6 +144806,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; @@ -144846,6 +144861,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; }; @@ -144888,6 +144908,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; }; @@ -144906,8 +144931,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) { @@ -144915,6 +144942,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; }; @@ -146737,6 +146766,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -146762,6 +146792,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 @@ -146788,6 +146826,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; }; @@ -146828,6 +146868,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; @@ -146868,6 +146912,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; }; @@ -146888,6 +146937,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; }; @@ -146904,10 +146958,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; }; @@ -146937,6 +146995,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; })(); @@ -147813,6 +148123,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -147824,6 +148135,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) @@ -147838,6 +148150,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 @@ -147864,6 +148184,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; }; @@ -147894,7 +148217,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) @@ -147904,6 +148227,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; @@ -147944,6 +148290,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; }; @@ -147964,6 +148318,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; }; @@ -147980,10 +148341,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; }; @@ -148622,30 +148991,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; })(); /** @@ -149371,6 +149985,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -149382,6 +149997,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) @@ -149396,6 +150012,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 @@ -149422,6 +150046,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; }; @@ -149462,6 +150089,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; @@ -149508,6 +150141,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; }; @@ -149551,6 +150193,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; }; @@ -149567,10 +150219,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; }; @@ -149623,37 +150282,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) @@ -149661,80 +150307,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: @@ -149746,36 +150389,257 @@ }; /** - * 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) { + 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; @@ -149866,6 +150730,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 @@ -149880,6 +150745,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; @@ -149904,6 +150770,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 @@ -149926,6 +150793,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -149976,6 +150844,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 @@ -150097,6 +150973,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; }; @@ -150169,6 +151048,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 = []; @@ -150271,6 +151156,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"; @@ -150325,6 +151217,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -150377,6 +151270,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"); @@ -150440,6 +151340,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -150505,6 +151409,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -150561,6 +151466,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; }; @@ -150609,6 +151519,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 */ /** @@ -150714,6 +151625,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 @@ -150766,6 +151685,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; }; @@ -150858,6 +151779,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -150971,6 +151896,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; }; @@ -151070,6 +152004,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; }; @@ -151099,6 +152053,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; @@ -151144,6 +152099,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; }; @@ -153188,6 +154145,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 */ /** @@ -153248,6 +154206,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 @@ -153285,6 +154251,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; }; @@ -153347,6 +154315,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -153415,10 +154387,19 @@ 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 * @memberof google.protobuf.EnumDescriptorProto @@ -153464,6 +154445,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; }; @@ -153488,6 +154489,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; @@ -153508,6 +154510,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; }; @@ -155826,6 +156830,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 @@ -155947,6 +156952,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 @@ -156029,6 +157042,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(); @@ -156132,6 +157147,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 = []; @@ -156271,6 +157290,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"; @@ -156464,6 +157488,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"); @@ -156566,6 +157595,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; } @@ -156599,6 +157629,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) @@ -156873,6 +157905,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -156914,103 +157947,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; @@ -157605,6 +159124,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 */ @@ -157648,6 +159168,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 @@ -157686,6 +159214,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(); @@ -157737,6 +159267,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 = []; @@ -157789,6 +159323,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"; @@ -157822,6 +159361,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"); @@ -157854,6 +159398,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -157861,6 +159406,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) @@ -159300,6 +160847,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 */ /** @@ -159365,6 +160914,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 @@ -159401,6 +160966,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; }; @@ -159461,6 +161030,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; @@ -159551,6 +161128,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; }; @@ -159690,6 +161287,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; }; @@ -159713,6 +161358,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; @@ -159726,6 +161373,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; }; @@ -159853,6 +161504,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; })(); @@ -160037,6 +161901,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -160054,6 +161919,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -160102,6 +161968,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -160154,6 +162024,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -160262,7 +162136,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 */ /** @@ -160289,12 +162164,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. @@ -160320,10 +162203,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; }; @@ -160364,8 +162249,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: @@ -160408,6 +162297,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -160420,10 +162310,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; }; @@ -160451,6 +162346,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -160492,10 +162391,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; }; @@ -160514,13 +162418,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; }; @@ -161735,6 +163642,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-sql/protos/protos.json b/packages/google-cloud-sql/protos/protos.json index bc666cfd4e7d..be60ad5717af 100644 --- a/packages/google-cloud-sql/protos/protos.json +++ b/packages/google-cloud-sql/protos/protos.json @@ -15951,8 +15951,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": { "http": { @@ -16076,6 +16075,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -16216,6 +16219,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 + } + } } } }, @@ -16273,6 +16298,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -16334,6 +16364,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -16455,6 +16498,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -16468,6 +16516,14 @@ } } } + }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } } } }, @@ -16490,12 +16546,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, @@ -16534,6 +16597,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -16622,6 +16690,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -16847,6 +16919,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -16897,7 +16973,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -17061,6 +17144,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -17196,7 +17280,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -17224,6 +17309,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -17293,6 +17382,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 + } + } } } }, @@ -17381,6 +17490,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -17523,6 +17636,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -17533,6 +17647,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -17543,6 +17658,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -17553,6 +17669,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -17563,7 +17680,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" } }, @@ -17573,27 +17691,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, @@ -17638,7 +17767,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -17653,6 +17788,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 + } + } + } } } }, @@ -17680,11 +17842,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -17697,6 +17874,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -17782,6 +17965,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { diff --git a/packages/google-cloud-sql/samples/generated/v1/snippet_metadata_google.cloud.sql.v1.json b/packages/google-cloud-sql/samples/generated/v1/snippet_metadata_google.cloud.sql.v1.json index eebb8ef8de18..76103b57b6ed 100644 --- a/packages/google-cloud-sql/samples/generated/v1/snippet_metadata_google.cloud.sql.v1.json +++ b/packages/google-cloud-sql/samples/generated/v1/snippet_metadata_google.cloud.sql.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-sql", - "version": "0.24.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-sql/samples/generated/v1beta4/snippet_metadata_google.cloud.sql.v1beta4.json b/packages/google-cloud-sql/samples/generated/v1beta4/snippet_metadata_google.cloud.sql.v1beta4.json index 477eae4f43d4..3806a1cf62ff 100644 --- a/packages/google-cloud-sql/samples/generated/v1beta4/snippet_metadata_google.cloud.sql.v1beta4.json +++ b/packages/google-cloud-sql/samples/generated/v1beta4/snippet_metadata_google.cloud.sql.v1beta4.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-sql", - "version": "0.24.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-sql/src/v1/index.ts b/packages/google-cloud-sql/src/v1/index.ts index fa8a89f713a8..3e843e173570 100644 --- a/packages/google-cloud-sql/src/v1/index.ts +++ b/packages/google-cloud-sql/src/v1/index.ts @@ -16,19 +16,19 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** - -export {SqlBackupRunsServiceClient} from './sql_backup_runs_service_client'; -export {SqlBackupsServiceClient} from './sql_backups_service_client'; -export {SqlConnectServiceClient} from './sql_connect_service_client'; -export {SqlDatabasesServiceClient} from './sql_databases_service_client'; - -export {SqlFeatureEligibilityServiceClient} from './sql_feature_eligibility_service_client'; -export {SqlFlagsServiceClient} from './sql_flags_service_client'; - - -export {SqlInstancesServiceClient} from './sql_instances_service_client'; -export {SqlOperationsServiceClient} from './sql_operations_service_client'; - -export {SqlSslCertsServiceClient} from './sql_ssl_certs_service_client'; -export {SqlTiersServiceClient} from './sql_tiers_service_client'; -export {SqlUsersServiceClient} from './sql_users_service_client'; +export { SqlAvailableDatabaseVersionsServiceClient } from './sql_available_database_versions_service_client'; +export { SqlBackupRunsServiceClient } from './sql_backup_runs_service_client'; +export { SqlBackupsServiceClient } from './sql_backups_service_client'; +export { SqlConnectServiceClient } from './sql_connect_service_client'; +export { SqlDatabasesServiceClient } from './sql_databases_service_client'; +export { SqlEventsServiceClient } from './sql_events_service_client'; +export { SqlFeatureEligibilityServiceClient } from './sql_feature_eligibility_service_client'; +export { SqlFlagsServiceClient } from './sql_flags_service_client'; +export { SqlIamPoliciesServiceClient } from './sql_iam_policies_service_client'; +export { SqlInstanceNamesServiceClient } from './sql_instance_names_service_client'; +export { SqlInstancesServiceClient } from './sql_instances_service_client'; +export { SqlOperationsServiceClient } from './sql_operations_service_client'; +export { SqlRegionsServiceClient } from './sql_regions_service_client'; +export { SqlSslCertsServiceClient } from './sql_ssl_certs_service_client'; +export { SqlTiersServiceClient } from './sql_tiers_service_client'; +export { SqlUsersServiceClient } from './sql_users_service_client'; diff --git a/packages/google-cloud-sql/src/v1/sql_backup_runs_service_client.ts b/packages/google-cloud-sql/src/v1/sql_backup_runs_service_client.ts index e6258c7ae72b..582b1c1f4ae2 100644 --- a/packages/google-cloud-sql/src/v1/sql_backup_runs_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_backup_runs_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlBackupRunsServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlBackupRunsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlBackupRunsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlBackupRunsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlBackupRunsServiceClient. @@ -101,21 +108,42 @@ export class SqlBackupRunsServiceClient { * const client = new SqlBackupRunsServiceClient({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 SqlBackupRunsServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlBackupRunsServiceClient { 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 +182,11 @@ export class SqlBackupRunsServiceClient { } 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,14 +208,17 @@ export class SqlBackupRunsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlBackupRunsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlBackupRunsService', + 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 @@ -222,36 +249,40 @@ export class SqlBackupRunsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlBackupRunsService. this.sqlBackupRunsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlBackupRunsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlBackupRunsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlBackupRunsService, - 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 sqlBackupRunsServiceStubMethods = - ['delete', 'get', 'insert', 'list']; + const sqlBackupRunsServiceStubMethods = ['delete', 'get', 'insert', 'list']; for (const methodName of sqlBackupRunsServiceStubMethods) { const callPromise = this.sqlBackupRunsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlBackupRunsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlBackupRunsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlBackupRunsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlBackupRunsServiceClient { * 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; @@ -334,413 +378,549 @@ export class SqlBackupRunsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes the backup taken by a backup run. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.id - * The ID of the backup run to delete. To find a backup run ID, use the - * [list](https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1/backupRuns/list) - * method. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_backup_runs_service.delete.js - * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Delete_async - */ + /** + * Deletes the backup taken by a backup run. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.id + * The ID of the backup run to delete. To find a backup run ID, use the + * [list](https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1/backupRuns/list) + * method. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_backup_runs_service.delete.js + * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'id': request.id?.toString() ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + id: request.id?.toString() ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a backup run. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.id - * The ID of this backup run. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.BackupRun|BackupRun}. - * Please see the {@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/sql_backup_runs_service.get.js - * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Get_async - */ + /** + * Retrieves a resource containing information about a backup run. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.id + * The ID of this backup run. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.BackupRun|BackupRun}. + * Please see the {@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/sql_backup_runs_service.get.js + * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'id': request.id?.toString() ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + id: request.id?.toString() ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IBackupRun, + | protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IBackupRun, - protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IBackupRun, + protos.google.cloud.sql.v1.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 backup run on demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.BackupRun} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_backup_runs_service.insert.js - * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Insert_async - */ + /** + * Creates a new backup run on demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.BackupRun} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_backup_runs_service.insert.js + * region_tag:sqladmin_v1_generated_SqlBackupRunsService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlBackupRunsInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all backup runs associated with the project or a given instance - * and configuration in the reverse chronological order of the backup - * initiation time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID, or "-" for all instances. This does not include - * the project ID. - * @param {number} request.maxResults - * Maximum number of backup runs per response. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.BackupRunsListResponse|BackupRunsListResponse}. - * Please see the {@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/sql_backup_runs_service.list.js - * region_tag:sqladmin_v1_generated_SqlBackupRunsService_List_async - */ + /** + * Lists all backup runs associated with the project or a given instance + * and configuration in the reverse chronological order of the backup + * initiation time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID, or "-" for all instances. This does not include + * the project ID. + * @param {number} request.maxResults + * Maximum number of backup runs per response. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.BackupRunsListResponse|BackupRunsListResponse}. + * Please see the {@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/sql_backup_runs_service.list.js + * region_tag:sqladmin_v1_generated_SqlBackupRunsService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlBackupRunsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IBackupRunsListResponse, + | protos.google.cloud.sql.v1.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IBackupRunsListResponse, - protos.google.cloud.sql.v1.ISqlBackupRunsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IBackupRunsListResponse, + protos.google.cloud.sql.v1.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -775,12 +955,11 @@ export class SqlBackupRunsServiceClient { | 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. @@ -813,7 +992,7 @@ export class SqlBackupRunsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -829,7 +1008,7 @@ export class SqlBackupRunsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -866,13 +1045,15 @@ export class SqlBackupRunsServiceClient { */ close(): Promise { if (this.sqlBackupRunsServiceStub && !this._terminated) { - return this.sqlBackupRunsServiceStub.then(stub => { + return this.sqlBackupRunsServiceStub.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-sql/src/v1/sql_backups_service_client.ts b/packages/google-cloud-sql/src/v1/sql_backups_service_client.ts index e564a09bad51..1931f7ec4f63 100644 --- a/packages/google-cloud-sql/src/v1/sql_backups_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_backups_service_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 @@ -43,7 +52,7 @@ export class SqlBackupsServiceClient { 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('sql'); @@ -56,10 +65,10 @@ export class SqlBackupsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlBackupsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlBackupsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlBackupsServiceClient. @@ -100,21 +109,42 @@ export class SqlBackupsServiceClient { * const client = new SqlBackupsServiceClient({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 SqlBackupsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +169,7 @@ export class SqlBackupsServiceClient { 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; @@ -153,15 +183,11 @@ export class SqlBackupsServiceClient { } 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 { @@ -183,10 +209,10 @@ export class SqlBackupsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -194,14 +220,20 @@ export class SqlBackupsServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlBackupsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlBackupsService', + 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 @@ -232,37 +264,46 @@ export class SqlBackupsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlBackupsService. this.sqlBackupsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlBackupsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlBackupsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlBackupsService, - 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 sqlBackupsServiceStubMethods = - ['createBackup', 'getBackup', 'listBackups', 'updateBackup', 'deleteBackup']; + const sqlBackupsServiceStubMethods = [ + 'createBackup', + 'getBackup', + 'listBackups', + 'updateBackup', + 'deleteBackup', + ]; for (const methodName of sqlBackupsServiceStubMethods) { const callPromise = this.sqlBackupsServiceStub.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; @@ -277,8 +318,14 @@ export class SqlBackupsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -289,8 +336,14 @@ export class SqlBackupsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -323,7 +376,7 @@ export class SqlBackupsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -333,8 +386,9 @@ export class SqlBackupsServiceClient { * 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; @@ -345,490 +399,625 @@ export class SqlBackupsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a backup for a Cloud SQL instance. This API can be used only to - * create on-demand backups. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this backup is created. - * Format: projects/{project} - * @param {google.cloud.sql.v1.Backup} request.backup - * Required. The Backup to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_backups_service.create_backup.js - * region_tag:sqladmin_v1_generated_SqlBackupsService_CreateBackup_async - */ + /** + * Creates a backup for a Cloud SQL instance. This API can be used only to + * create on-demand backups. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this backup is created. + * Format: projects/{project} + * @param {google.cloud.sql.v1.Backup} request.backup + * Required. The Backup to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_backups_service.create_backup.js + * region_tag:sqladmin_v1_generated_SqlBackupsService_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.sql.v1.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.sql.v1.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.sql.v1.ICreateBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ICreateBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.sql.v1.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ICreateBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('createBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ICreateBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the backup to retrieve. - * Format: projects/{project}/backups/{backup} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.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/sql_backups_service.get_backup.js - * region_tag:sqladmin_v1_generated_SqlBackupsService_GetBackup_async - */ + /** + * Retrieves a resource containing information about a backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the backup to retrieve. + * Format: projects/{project}/backups/{backup} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.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/sql_backups_service.get_backup.js + * region_tag:sqladmin_v1_generated_SqlBackupsService_GetBackup_async + */ getBackup( - request?: protos.google.cloud.sql.v1.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.v1.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.sql.v1.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.sql.v1.IGetBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGetBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.sql.v1.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.v1.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.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.sql.v1.IBackup, - protos.google.cloud.sql.v1.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IBackup, + protos.google.cloud.sql.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.sql.v1.IBackup, - protos.google.cloud.sql.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.sql.v1.IBackup, + protos.google.cloud.sql.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; }); } -/** - * Updates the retention period and description of the backup. You can use - * this API to update final backups only. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.sql.v1.Backup} request.backup - * Required. The backup to update. - * The backup’s `name` field is used to identify the backup to update. - * Format: projects/{project}/backups/{backup} - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields that you can update. You can update only the description - * and retention period of the final backup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_backups_service.update_backup.js - * region_tag:sqladmin_v1_generated_SqlBackupsService_UpdateBackup_async - */ + /** + * Updates the retention period and description of the backup. You can use + * this API to update final backups only. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.sql.v1.Backup} request.backup + * Required. The backup to update. + * The backup’s `name` field is used to identify the backup to update. + * Format: projects/{project}/backups/{backup} + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields that you can update. You can update only the description + * and retention period of the final backup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_backups_service.update_backup.js + * region_tag:sqladmin_v1_generated_SqlBackupsService_UpdateBackup_async + */ updateBackup( - request?: protos.google.cloud.sql.v1.IUpdateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.IUpdateBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | undefined, + {} | undefined, + ] + >; updateBackup( - request: protos.google.cloud.sql.v1.IUpdateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IUpdateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request: protos.google.cloud.sql.v1.IUpdateBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IUpdateBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request?: protos.google.cloud.sql.v1.IUpdateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.IUpdateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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}); this._log.info('updateBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IUpdateBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IUpdateBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 the backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the backup to delete. - * Format: projects/{project}/backups/{backup} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_backups_service.delete_backup.js - * region_tag:sqladmin_v1_generated_SqlBackupsService_DeleteBackup_async - */ + /** + * Deletes the backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the backup to delete. + * Format: projects/{project}/backups/{backup} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_backups_service.delete_backup.js + * region_tag:sqladmin_v1_generated_SqlBackupsService_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.sql.v1.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.sql.v1.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.sql.v1.IDeleteBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IDeleteBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.sql.v1.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.IDeleteBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.IDeleteBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all backups associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.sql.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 associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.sql.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.sql.v1.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IBackup[], - protos.google.cloud.sql.v1.IListBackupsRequest|null, - protos.google.cloud.sql.v1.IListBackupsResponse - ]>; + request?: protos.google.cloud.sql.v1.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackup[], + protos.google.cloud.sql.v1.IListBackupsRequest | null, + protos.google.cloud.sql.v1.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.sql.v1.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.sql.v1.IListBackupsRequest, - protos.google.cloud.sql.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1.IBackup>): void; + request: protos.google.cloud.sql.v1.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.sql.v1.IListBackupsRequest, + protos.google.cloud.sql.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.sql.v1.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.sql.v1.IListBackupsRequest, - protos.google.cloud.sql.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1.IBackup>): void; + request: protos.google.cloud.sql.v1.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.sql.v1.IListBackupsRequest, + protos.google.cloud.sql.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.sql.v1.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.sql.v1.IListBackupsRequest, - protos.google.cloud.sql.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.sql.v1.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.sql.v1.IListBackupsRequest, - protos.google.cloud.sql.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1.IBackup>): - Promise<[ - protos.google.cloud.sql.v1.IBackup[], - protos.google.cloud.sql.v1.IListBackupsRequest|null, - protos.google.cloud.sql.v1.IListBackupsResponse - ]>|void { + protos.google.cloud.sql.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.sql.v1.IListBackupsRequest, + protos.google.cloud.sql.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1.IBackup + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IBackup[], + protos.google.cloud.sql.v1.IListBackupsRequest | null, + protos.google.cloud.sql.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.sql.v1.IListBackupsRequest, - protos.google.cloud.sql.v1.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.sql.v1.IListBackupsRequest, + protos.google.cloud.sql.v1.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -837,137 +1026,142 @@ export class SqlBackupsServiceClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.sql.v1.IBackup[], - protos.google.cloud.sql.v1.IListBackupsRequest|null, - protos.google.cloud.sql.v1.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.sql.v1.IBackup[], + protos.google.cloud.sql.v1.IListBackupsRequest | null, + protos.google.cloud.sql.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 parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @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.sql.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 parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @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.sql.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.sql.v1.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.sql.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 parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @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.sql.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/sql_backups_service.list_backups.js - * region_tag:sqladmin_v1_generated_SqlBackupsService_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 parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @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.sql.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/sql_backups_service.list_backups.js + * region_tag:sqladmin_v1_generated_SqlBackupsService_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.sql.v1.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.sql.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 @@ -1002,12 +1196,11 @@ export class SqlBackupsServiceClient { | 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. @@ -1040,7 +1233,7 @@ export class SqlBackupsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1056,7 +1249,7 @@ export class SqlBackupsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -1091,7 +1284,7 @@ export class SqlBackupsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1116,13 +1309,15 @@ export class SqlBackupsServiceClient { */ close(): Promise { if (this.sqlBackupsServiceStub && !this._terminated) { - return this.sqlBackupsServiceStub.then(stub => { + return this.sqlBackupsServiceStub.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-sql/src/v1/sql_connect_service_client.ts b/packages/google-cloud-sql/src/v1/sql_connect_service_client.ts index 6c84fc9a1284..55bcc54b96ae 100644 --- a/packages/google-cloud-sql/src/v1/sql_connect_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_connect_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlConnectServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlConnectServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlConnectServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlConnectServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlConnectServiceClient. @@ -101,21 +108,42 @@ export class SqlConnectServiceClient { * const client = new SqlConnectServiceClient({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 SqlConnectServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlConnectServiceClient { 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 +182,11 @@ export class SqlConnectServiceClient { } 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,14 +208,17 @@ export class SqlConnectServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlConnectService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlConnectService', + 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 @@ -222,36 +249,43 @@ export class SqlConnectServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlConnectService. this.sqlConnectServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlConnectService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlConnectService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlConnectService, - 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 sqlConnectServiceStubMethods = - ['getConnectSettings', 'generateEphemeralCert']; + const sqlConnectServiceStubMethods = [ + 'getConnectSettings', + 'generateEphemeralCert', + ]; for (const methodName of sqlConnectServiceStubMethods) { const callPromise = this.sqlConnectServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +300,14 @@ export class SqlConnectServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +318,14 @@ export class SqlConnectServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +358,7 @@ export class SqlConnectServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +368,9 @@ export class SqlConnectServiceClient { * 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; @@ -334,217 +381,291 @@ export class SqlConnectServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves connect settings about a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.protobuf.Timestamp} [request.readTime] - * Optional. Optional snapshot read timestamp to trade freshness for - * performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.ConnectSettings|ConnectSettings}. - * Please see the {@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/sql_connect_service.get_connect_settings.js - * region_tag:sqladmin_v1_generated_SqlConnectService_GetConnectSettings_async - */ + /** + * Retrieves connect settings about a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.protobuf.Timestamp} [request.readTime] + * Optional. Optional snapshot read timestamp to trade freshness for + * performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.ConnectSettings|ConnectSettings}. + * Please see the {@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/sql_connect_service.get_connect_settings.js + * region_tag:sqladmin_v1_generated_SqlConnectService_GetConnectSettings_async + */ getConnectSettings( - request?: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | undefined, + {} | undefined, + ] + >; getConnectSettings( - request: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; getConnectSettings( - request: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, - callback: Callback< - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, + callback: Callback< + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | null | undefined, + {} | null | undefined + >, + ): void; getConnectSettings( - request?: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.IGetConnectSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getConnectSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IConnectSettings, + | protos.google.cloud.sql.v1.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConnectSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConnectSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IConnectSettings, - protos.google.cloud.sql.v1.IGetConnectSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConnectSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getConnectSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IConnectSettings, + protos.google.cloud.sql.v1.IGetConnectSettingsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getConnectSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.publicKey - * PEM encoded public key to include in the signed certificate. - * @param {string} [request.accessToken] - * Optional. Access token to include in the signed certificate. - * @param {google.protobuf.Timestamp} [request.readTime] - * Optional. Optional snapshot read timestamp to trade freshness for - * performance. - * @param {google.protobuf.Duration} [request.validDuration] - * Optional. If set, it will contain the cert valid duration. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.GenerateEphemeralCertResponse|GenerateEphemeralCertResponse}. - * Please see the {@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/sql_connect_service.generate_ephemeral_cert.js - * region_tag:sqladmin_v1_generated_SqlConnectService_GenerateEphemeralCert_async - */ + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.publicKey + * PEM encoded public key to include in the signed certificate. + * @param {string} [request.accessToken] + * Optional. Access token to include in the signed certificate. + * @param {google.protobuf.Timestamp} [request.readTime] + * Optional. Optional snapshot read timestamp to trade freshness for + * performance. + * @param {google.protobuf.Duration} [request.validDuration] + * Optional. If set, it will contain the cert valid duration. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.GenerateEphemeralCertResponse|GenerateEphemeralCertResponse}. + * Please see the {@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/sql_connect_service.generate_ephemeral_cert.js + * region_tag:sqladmin_v1_generated_SqlConnectService_GenerateEphemeralCert_async + */ generateEphemeralCert( - request?: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest | undefined, + {} | undefined, + ] + >; generateEphemeralCert( - request: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateEphemeralCert( - request: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, - callback: Callback< - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, + callback: Callback< + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateEphemeralCert( - request?: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('generateEphemeralCert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateEphemeralCert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateEphemeralCert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateEphemeralCert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .generateEphemeralCert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse, + protos.google.cloud.sql.v1.IGenerateEphemeralCertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('generateEphemeralCert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -579,12 +700,11 @@ export class SqlConnectServiceClient { | 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. @@ -617,7 +737,7 @@ export class SqlConnectServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -633,7 +753,7 @@ export class SqlConnectServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -670,13 +790,15 @@ export class SqlConnectServiceClient { */ close(): Promise { if (this.sqlConnectServiceStub && !this._terminated) { - return this.sqlConnectServiceStub.then(stub => { + return this.sqlConnectServiceStub.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-sql/src/v1/sql_databases_service_client.ts b/packages/google-cloud-sql/src/v1/sql_databases_service_client.ts index 999cef663be5..6b679b46644a 100644 --- a/packages/google-cloud-sql/src/v1/sql_databases_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_databases_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlDatabasesServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlDatabasesServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlDatabasesServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlDatabasesServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlDatabasesServiceClient. @@ -101,21 +108,42 @@ export class SqlDatabasesServiceClient { * const client = new SqlDatabasesServiceClient({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 SqlDatabasesServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlDatabasesServiceClient { 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 +182,11 @@ export class SqlDatabasesServiceClient { } 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,14 +208,17 @@ export class SqlDatabasesServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlDatabasesService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlDatabasesService', + 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 @@ -222,36 +249,47 @@ export class SqlDatabasesServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlDatabasesService. this.sqlDatabasesServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlDatabasesService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlDatabasesService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlDatabasesService, - 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 sqlDatabasesServiceStubMethods = - ['delete', 'get', 'insert', 'list', 'patch', 'update']; + const sqlDatabasesServiceStubMethods = [ + 'delete', + 'get', + 'insert', + 'list', + 'patch', + 'update', + ]; for (const methodName of sqlDatabasesServiceStubMethods) { const callPromise = this.sqlDatabasesServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +304,14 @@ export class SqlDatabasesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +322,14 @@ export class SqlDatabasesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +362,7 @@ export class SqlDatabasesServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +372,9 @@ export class SqlDatabasesServiceClient { * 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; @@ -334,611 +385,811 @@ export class SqlDatabasesServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes a database from a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be deleted in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_databases_service.delete.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_Delete_async - */ + /** + * Deletes a database from a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be deleted in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_databases_service.delete.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a database inside a Cloud - * SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.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/sql_databases_service.get.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_Get_async - */ + /** + * Retrieves a resource containing information about a database inside a Cloud + * SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.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/sql_databases_service.get.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IDatabase, - protos.google.cloud.sql.v1.ISqlDatabasesGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IDatabase, + protos.google.cloud.sql.v1.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Inserts a resource containing information about a database inside a Cloud - * SQL instance. - * - * **Note:** You can't modify the default character set and collation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_databases_service.insert.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_Insert_async - */ + /** + * Inserts a resource containing information about a database inside a Cloud + * SQL instance. + * + * **Note:** You can't modify the default character set and collation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_databases_service.insert.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 databases in the specified Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.DatabasesListResponse|DatabasesListResponse}. - * Please see the {@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/sql_databases_service.list.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_List_async - */ + /** + * Lists databases in the specified Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.DatabasesListResponse|DatabasesListResponse}. + * Please see the {@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/sql_databases_service.list.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IDatabasesListResponse, + | protos.google.cloud.sql.v1.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IDatabasesListResponse, - protos.google.cloud.sql.v1.ISqlDatabasesListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IDatabasesListResponse, + protos.google.cloud.sql.v1.ISqlDatabasesListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Partially updates a resource containing information about a database inside - * a Cloud SQL instance. This method supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be updated in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_databases_service.patch.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_Patch_async - */ + /** + * Partially updates a resource containing information about a database inside + * a Cloud SQL instance. This method supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be updated in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_databases_service.patch.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_Patch_async + */ patch( - request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + >; patch( - request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; patch( - request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; patch( - request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('patch request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('patch response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.patch(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('patch response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .patch(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('patch response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a resource containing information about a database inside a Cloud - * SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be updated in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_databases_service.update.js - * region_tag:sqladmin_v1_generated_SqlDatabasesService_Update_async - */ + /** + * Updates a resource containing information about a database inside a Cloud + * SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be updated in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_databases_service.update.js + * region_tag:sqladmin_v1_generated_SqlDatabasesService_Update_async + */ update( - request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -973,12 +1224,11 @@ export class SqlDatabasesServiceClient { | 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. @@ -1011,7 +1261,7 @@ export class SqlDatabasesServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1027,7 +1277,7 @@ export class SqlDatabasesServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -1064,13 +1314,15 @@ export class SqlDatabasesServiceClient { */ close(): Promise { if (this.sqlDatabasesServiceStub && !this._terminated) { - return this.sqlDatabasesServiceStub.then(stub => { + return this.sqlDatabasesServiceStub.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-sql/src/v1/sql_feature_eligibility_service_client.ts b/packages/google-cloud-sql/src/v1/sql_feature_eligibility_service_client.ts index 15082a1ebb78..55b053d0a121 100644 --- a/packages/google-cloud-sql/src/v1/sql_feature_eligibility_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_feature_eligibility_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlFeatureEligibilityServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlFeatureEligibilityServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlFeatureEligibilityServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlFeatureEligibilityServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlFeatureEligibilityServiceClient. @@ -101,21 +108,43 @@ export class SqlFeatureEligibilityServiceClient { * const client = new SqlFeatureEligibilityServiceClient({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 SqlFeatureEligibilityServiceClient; - 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 SqlFeatureEligibilityServiceClient; + 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 = 'sqladmin.' + 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 +169,7 @@ export class SqlFeatureEligibilityServiceClient { 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 +183,11 @@ export class SqlFeatureEligibilityServiceClient { } 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,14 +209,17 @@ export class SqlFeatureEligibilityServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlFeatureEligibilityService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlFeatureEligibilityService', + 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 @@ -222,11 +250,16 @@ export class SqlFeatureEligibilityServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlFeatureEligibilityService. this.sqlFeatureEligibilityServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlFeatureEligibilityService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.sql.v1.SqlFeatureEligibilityService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlFeatureEligibilityService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.sql.v1 + .SqlFeatureEligibilityService, + this._opts, + this._providedCustomServicePath, + ) as Promise<{ [method: string]: Function }>; return this.sqlFeatureEligibilityServiceStub; } @@ -237,8 +270,14 @@ export class SqlFeatureEligibilityServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -249,8 +288,14 @@ export class SqlFeatureEligibilityServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -290,8 +335,9 @@ export class SqlFeatureEligibilityServiceClient { * 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; @@ -303,7 +349,7 @@ export class SqlFeatureEligibilityServiceClient { // -- Service calls -- // ------------------- -/** + /** * Gets information about a location. * * @param {Object} request @@ -338,12 +384,11 @@ export class SqlFeatureEligibilityServiceClient { | 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. @@ -376,7 +421,7 @@ export class SqlFeatureEligibilityServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -392,7 +437,7 @@ export class SqlFeatureEligibilityServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -429,13 +474,15 @@ export class SqlFeatureEligibilityServiceClient { */ close(): Promise { if (this.sqlFeatureEligibilityServiceStub && !this._terminated) { - return this.sqlFeatureEligibilityServiceStub.then(stub => { + return this.sqlFeatureEligibilityServiceStub.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-sql/src/v1/sql_flags_service_client.ts b/packages/google-cloud-sql/src/v1/sql_flags_service_client.ts index deeadf3118b6..b30f40542afd 100644 --- a/packages/google-cloud-sql/src/v1/sql_flags_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_flags_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlFlagsServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlFlagsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlFlagsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlFlagsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlFlagsServiceClient. @@ -101,21 +108,42 @@ export class SqlFlagsServiceClient { * const client = new SqlFlagsServiceClient({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 SqlFlagsServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlFlagsServiceClient { 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 +182,11 @@ export class SqlFlagsServiceClient { } 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,14 +208,17 @@ export class SqlFlagsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlFlagsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlFlagsService', + 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 @@ -222,36 +249,40 @@ export class SqlFlagsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlFlagsService. this.sqlFlagsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlFlagsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlFlagsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlFlagsService, - 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 sqlFlagsServiceStubMethods = - ['list']; + const sqlFlagsServiceStubMethods = ['list']; for (const methodName of sqlFlagsServiceStubMethods) { const callPromise = this.sqlFlagsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlFlagsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlFlagsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlFlagsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlFlagsServiceClient { * 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; @@ -334,101 +378,132 @@ export class SqlFlagsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Lists all available database flags for Cloud SQL instances. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.databaseVersion - * Database type and version you want to retrieve flags for. By default, this - * method returns flags for all database types and versions. - * @param {google.cloud.sql.v1.SqlFlagScope} [request.flagScope] - * Optional. Specify the scope of flags to be returned by SqlFlagsListService. - * Return list of database flags if unspecified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.FlagsListResponse|FlagsListResponse}. - * Please see the {@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/sql_flags_service.list.js - * region_tag:sqladmin_v1_generated_SqlFlagsService_List_async - */ + /** + * Lists all available database flags for Cloud SQL instances. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.databaseVersion + * Database type and version you want to retrieve flags for. By default, this + * method returns flags for all database types and versions. + * @param {google.cloud.sql.v1.SqlFlagScope} [request.flagScope] + * Optional. Specify the scope of flags to be returned by SqlFlagsListService. + * Return list of database flags if unspecified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.FlagsListResponse|FlagsListResponse}. + * Please see the {@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/sql_flags_service.list.js + * region_tag:sqladmin_v1_generated_SqlFlagsService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlFlagsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlFlagsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlFlagsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlFlagsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlFlagsListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlFlagsListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlFlagsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlFlagsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IFlagsListResponse, - protos.google.cloud.sql.v1.ISqlFlagsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IFlagsListResponse, + protos.google.cloud.sql.v1.ISqlFlagsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -463,12 +538,11 @@ export class SqlFlagsServiceClient { | 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. @@ -501,7 +575,7 @@ export class SqlFlagsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -517,7 +591,7 @@ export class SqlFlagsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -554,13 +628,15 @@ export class SqlFlagsServiceClient { */ close(): Promise { if (this.sqlFlagsServiceStub && !this._terminated) { - return this.sqlFlagsServiceStub.then(stub => { + return this.sqlFlagsServiceStub.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-sql/src/v1/sql_instances_service_client.ts b/packages/google-cloud-sql/src/v1/sql_instances_service_client.ts index 754b0a26a55a..d3bb1f466574 100644 --- a/packages/google-cloud-sql/src/v1/sql_instances_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_instances_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlInstancesServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlInstancesServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlInstancesServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlInstancesServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlInstancesServiceClient. @@ -100,21 +107,42 @@ export class SqlInstancesServiceClient { * const client = new SqlInstancesServiceClient({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 SqlInstancesServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlInstancesServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlInstancesServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlInstancesServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/backupVaults/{backupvault}/dataSources/{datasource}/backups/{backup}' + 'projects/{project}/locations/{location}/backupVaults/{backupvault}/dataSources/{datasource}/backups/{backup}', ), networkPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/global/networks/{network}' + 'projects/{project}/global/networks/{network}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlInstancesService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlInstancesService', + 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 @@ -224,36 +251,84 @@ export class SqlInstancesServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlInstancesService. this.sqlInstancesServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlInstancesService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlInstancesService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlInstancesService, - 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 sqlInstancesServiceStubMethods = - ['addServerCa', 'addServerCertificate', 'addEntraIdCertificate', 'clone', 'delete', 'demoteMaster', 'demote', 'export', 'failover', 'reencrypt', 'get', 'import', 'insert', 'list', 'listServerCas', 'listServerCertificates', 'listEntraIdCertificates', 'patch', 'promoteReplica', 'switchover', 'resetSslConfig', 'restart', 'restoreBackup', 'rotateServerCa', 'rotateServerCertificate', 'rotateEntraIdCertificate', 'startReplica', 'stopReplica', 'truncateLog', 'update', 'createEphemeral', 'rescheduleMaintenance', 'verifyExternalSyncSettings', 'startExternalSync', 'performDiskShrink', 'getDiskShrinkConfig', 'resetReplicaSize', 'getLatestRecoveryTime', 'executeSql', 'acquireSsrsLease', 'releaseSsrsLease', 'preCheckMajorVersionUpgrade', 'pointInTimeRestore']; + const sqlInstancesServiceStubMethods = [ + 'addServerCa', + 'addServerCertificate', + 'addEntraIdCertificate', + 'clone', + 'delete', + 'demoteMaster', + 'demote', + 'export', + 'failover', + 'reencrypt', + 'get', + 'import', + 'insert', + 'list', + 'listServerCas', + 'listServerCertificates', + 'listEntraIdCertificates', + 'patch', + 'promoteReplica', + 'switchover', + 'resetSslConfig', + 'restart', + 'restoreBackup', + 'rotateServerCa', + 'rotateServerCertificate', + 'rotateEntraIdCertificate', + 'startReplica', + 'stopReplica', + 'truncateLog', + 'update', + 'createEphemeral', + 'rescheduleMaintenance', + 'verifyExternalSyncSettings', + 'startExternalSync', + 'performDiskShrink', + 'getDiskShrinkConfig', + 'resetReplicaSize', + 'getLatestRecoveryTime', + 'executeSql', + 'acquireSsrsLease', + 'releaseSsrsLease', + 'preCheckMajorVersionUpgrade', + 'pointInTimeRestore', + ]; for (const methodName of sqlInstancesServiceStubMethods) { const callPromise = this.sqlInstancesServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +343,14 @@ export class SqlInstancesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +361,14 @@ export class SqlInstancesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +401,7 @@ export class SqlInstancesServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +411,9 @@ export class SqlInstancesServiceClient { * 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; @@ -336,4348 +424,6190 @@ export class SqlInstancesServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Adds a new trusted Certificate Authority (CA) version for the specified - * instance. Required to prepare for a certificate rotation. If a CA version - * was previously added but never used in a certificate rotation, this - * operation replaces that version. There cannot be more than one CA version - * waiting to be rotated in. For instances that have enabled Certificate - * Authority Service (CAS) based server CA, use AddServerCertificate to add a - * new server certificate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.add_server_ca.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_AddServerCa_async - */ + /** + * Adds a new trusted Certificate Authority (CA) version for the specified + * instance. Required to prepare for a certificate rotation. If a CA version + * was previously added but never used in a certificate rotation, this + * operation replaces that version. There cannot be more than one CA version + * waiting to be rotated in. For instances that have enabled Certificate + * Authority Service (CAS) based server CA, use AddServerCertificate to add a + * new server certificate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.add_server_ca.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_AddServerCa_async + */ addServerCa( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest | undefined, + {} | undefined, + ] + >; addServerCa( - request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCa( - request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCa( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addServerCa request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addServerCa response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addServerCa(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest|undefined, - {}|undefined - ]) => { - this._log.info('addServerCa response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addServerCa(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addServerCa response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a new trusted server certificate version for the specified instance - * using Certificate Authority Service (CAS) server CA. Required to prepare - * for a certificate rotation. If a server certificate version was previously - * added but never used in a certificate rotation, this operation replaces - * that version. There cannot be more than one certificate version waiting to - * be rotated in. For instances not using CAS server CA, use AddServerCa - * instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.add_server_certificate.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_AddServerCertificate_async - */ + /** + * Add a new trusted server certificate version for the specified instance + * using Certificate Authority Service (CAS) server CA. Required to prepare + * for a certificate rotation. If a server certificate version was previously + * added but never used in a certificate rotation, this operation replaces + * that version. There cannot be more than one certificate version waiting to + * be rotated in. For instances not using CAS server CA, use AddServerCa + * instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.add_server_certificate.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_AddServerCertificate_async + */ addServerCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ] + >; addServerCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addServerCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addServerCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addServerCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('addServerCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addServerCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addServerCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Adds a new Entra ID certificate for the specified instance. If an Entra ID - * certificate was previously added but never used in a certificate rotation, - * this operation replaces that version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.add_entra_id_certificate.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_AddEntraIdCertificate_async - */ + /** + * Adds a new Entra ID certificate for the specified instance. If an Entra ID + * certificate was previously added but never used in a certificate rotation, + * this operation replaces that version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.add_entra_id_certificate.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_AddEntraIdCertificate_async + */ addEntraIdCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + >; addEntraIdCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addEntraIdCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addEntraIdCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addEntraIdCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addEntraIdCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addEntraIdCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('addEntraIdCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addEntraIdCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addEntraIdCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance as a clone of the source instance. Using this - * operation might cause your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. The ID of the Cloud SQL instance to be cloned (source). This does - * not include the project ID. - * @param {string} request.project - * Required. Project ID of the source as well as the clone Cloud SQL instance. - * @param {google.cloud.sql.v1.InstancesCloneRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.clone.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Clone_async - */ + /** + * Creates a Cloud SQL instance as a clone of the source instance. Using this + * operation might cause your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. The ID of the Cloud SQL instance to be cloned (source). This does + * not include the project ID. + * @param {string} request.project + * Required. Project ID of the source as well as the clone Cloud SQL instance. + * @param {google.cloud.sql.v1.InstancesCloneRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.clone.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Clone_async + */ clone( - request?: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ] + >; clone( - request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | null | undefined, + {} | null | undefined + >, + ): void; clone( - request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | null | undefined, + {} | null | undefined + >, + ): void; clone( - request?: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesCloneRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('clone request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('clone response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.clone(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesCloneRequest|undefined, - {}|undefined - ]) => { - this._log.info('clone response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .clone(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ]) => { + this._log.info('clone response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be deleted. - * @param {boolean} request.enableFinalBackup - * Flag to opt-in for final backup. By default, it is turned off. - * @param {number} [request.finalBackupTtlDays] - * Optional. Retention period of the final backup. - * @param {google.protobuf.Timestamp} [request.finalBackupExpiryTime] - * Optional. Final Backup expiration time. - * Timestamp in UTC of when this resource is considered expired. - * @param {string} [request.finalBackupDescription] - * Optional. The description of the final backup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.delete.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Delete_async - */ + /** + * Deletes a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be deleted. + * @param {boolean} request.enableFinalBackup + * Flag to opt-in for final backup. By default, it is turned off. + * @param {number} [request.finalBackupTtlDays] + * Optional. Retention period of the final backup. + * @param {google.protobuf.Timestamp} [request.finalBackupExpiryTime] + * Optional. Final Backup expiration time. + * Timestamp in UTC of when this resource is considered expired. + * @param {string} [request.finalBackupDescription] + * Optional. The description of the final backup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.delete.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Demotes the stand-alone instance to be a Cloud SQL read replica for an - * external database server. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance name. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesDemoteMasterRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.demote_master.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_DemoteMaster_async - */ + /** + * Demotes the stand-alone instance to be a Cloud SQL read replica for an + * external database server. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance name. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesDemoteMasterRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.demote_master.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_DemoteMaster_async + */ demoteMaster( - request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest | undefined, + {} | undefined, + ] + >; demoteMaster( - request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demoteMaster( - request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demoteMaster( - request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('demoteMaster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('demoteMaster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.demoteMaster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest|undefined, - {}|undefined - ]) => { - this._log.info('demoteMaster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .demoteMaster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesDemoteMasterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('demoteMaster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Demotes an existing standalone instance to be a Cloud SQL read replica - * for an external database server. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance name. - * @param {string} request.project - * Required. ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesDemoteRequest} request.body - * Required. The request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.demote.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Demote_async - */ - demote( - request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|undefined, {}|undefined - ]>; - demote( - request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): void; - demote( - request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): void; + /** + * Demotes an existing standalone instance to be a Cloud SQL read replica + * for an external database server. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance name. + * @param {string} request.project + * Required. ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesDemoteRequest} request.body + * Required. The request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.demote.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Demote_async + */ demote( - request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | undefined, + {} | undefined, + ] + >; + demote( + request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | null | undefined, + {} | null | undefined + >, + ): void; + demote( + request: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | null | undefined, + {} | null | undefined + >, + ): void; + demote( + request?: protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('demote request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('demote response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.demote(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest|undefined, - {}|undefined - ]) => { - this._log.info('demote response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .demote(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesDemoteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('demote response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL - * dump or CSV file. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be exported. - * @param {google.cloud.sql.v1.InstancesExportRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.export.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Export_async - */ + /** + * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL + * dump or CSV file. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be exported. + * @param {google.cloud.sql.v1.InstancesExportRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.export.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Export_async + */ export( - request?: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | undefined, + {} | undefined, + ] + >; export( - request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | null | undefined, + {} | null | undefined + >, + ): void; export( - request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | null | undefined, + {} | null | undefined + >, + ): void; export( - request?: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesExportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('export request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('export response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.export(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesExportRequest|undefined, - {}|undefined - ]) => { - this._log.info('export response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .export(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesExportRequest | undefined, + {} | undefined, + ]) => { + this._log.info('export response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Initiates a manual failover of a high availability (HA) primary instance - * to a standby instance, which becomes the primary instance. Users are - * then rerouted to the new primary. For more information, see the - * [Overview of high - * availability](https://cloud.google.com/sql/docs/mysql/high-availability) - * page in the Cloud SQL documentation. - * If using Legacy HA (MySQL only), this causes the instance to failover to - * its failover replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {google.cloud.sql.v1.InstancesFailoverRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.failover.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Failover_async - */ + /** + * Initiates a manual failover of a high availability (HA) primary instance + * to a standby instance, which becomes the primary instance. Users are + * then rerouted to the new primary. For more information, see the + * [Overview of high + * availability](https://cloud.google.com/sql/docs/mysql/high-availability) + * page in the Cloud SQL documentation. + * If using Legacy HA (MySQL only), this causes the instance to failover to + * its failover replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {google.cloud.sql.v1.InstancesFailoverRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.failover.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Failover_async + */ failover( - request?: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | undefined, + {} | undefined, + ] + >; failover( - request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; failover( - request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; failover( - request?: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('failover request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('failover response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.failover(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest|undefined, - {}|undefined - ]) => { - this._log.info('failover response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .failover(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesFailoverRequest | undefined, + {} | undefined, + ]) => { + this._log.info('failover response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reencrypt CMEK instance with latest key version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesReencryptRequest} request.body - * Reencrypt body that users 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 an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.reencrypt.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Reencrypt_async - */ + /** + * Reencrypt CMEK instance with latest key version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesReencryptRequest} request.body + * Reencrypt body that users 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 an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.reencrypt.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Reencrypt_async + */ reencrypt( - request?: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest | undefined, + {} | undefined, + ] + >; reencrypt( - request: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reencrypt( - request: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reencrypt( - request?: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('reencrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('reencrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.reencrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('reencrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .reencrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesReencryptRequest | undefined, + {} | undefined, + ]) => { + this._log.info('reencrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Database instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1.DatabaseInstance|DatabaseInstance}. - * Please see the {@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/sql_instances_service.get.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Get_async - */ + /** + * Retrieves a resource containing information about a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Database instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1.DatabaseInstance|DatabaseInstance}. + * Please see the {@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/sql_instances_service.get.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IDatabaseInstance, - protos.google.cloud.sql.v1.ISqlInstancesGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IDatabaseInstance, + protos.google.cloud.sql.v1.ISqlInstancesGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Imports data into a Cloud SQL instance from a SQL dump or CSV file in - * Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesImportRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.import.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Import_async - */ + /** + * Imports data into a Cloud SQL instance from a SQL dump or CSV file in + * Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesImportRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.import.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Import_async + */ import( - request?: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | undefined, + {} | undefined, + ] + >; import( - request: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | null | undefined, + {} | null | undefined + >, + ): void; import( - request: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | null | undefined, + {} | null | undefined + >, + ): void; import( - request?: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('import request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('import response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.import(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesImportRequest|undefined, - {}|undefined - ]) => { - this._log.info('import response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .import(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesImportRequest | undefined, + {} | undefined, + ]) => { + this._log.info('import response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.project - * Project ID of the project to which the newly created Cloud SQL instances - * should belong. - * @param {google.cloud.sql.v1.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.insert.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Insert_async - */ + /** + * Creates a new Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID of the project to which the newly created Cloud SQL instances + * should belong. + * @param {google.cloud.sql.v1.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.insert.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 instances under a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.filter - * A filter expression that filters resources listed in the response. - * The expression is in the form of field:value. For example, - * 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per - * their JSON representation, such as 'settings.userLabels.auto_start:true'. - * - * Multiple filter queries are space-separated. For example. - * 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each - * expression is an AND expression. However, you can include AND and OR - * expressions explicitly. - * @param {number} request.maxResults - * The maximum number of instances to return. The service may return fewer - * than this value. - * If unspecified, at most 500 instances are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project for which to list Cloud SQL instances. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.InstancesListResponse|InstancesListResponse}. - * Please see the {@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/sql_instances_service.list.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_List_async - */ - list( - request?: protos.google.cloud.sql.v1.ISqlInstancesListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|undefined, {}|undefined - ]>; - list( - request: protos.google.cloud.sql.v1.ISqlInstancesListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): void; + /** + * Lists instances under a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. + * The expression is in the form of field:value. For example, + * 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per + * their JSON representation, such as 'settings.userLabels.auto_start:true'. + * + * Multiple filter queries are space-separated. For example. + * 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each + * expression is an AND expression. However, you can include AND and OR + * expressions explicitly. + * @param {number} request.maxResults + * The maximum number of instances to return. The service may return fewer + * than this value. + * If unspecified, at most 500 instances are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project for which to list Cloud SQL instances. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.InstancesListResponse|InstancesListResponse}. + * Please see the {@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/sql_instances_service.list.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_List_async + */ list( - request: protos.google.cloud.sql.v1.ISqlInstancesListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): void; + request?: protos.google.cloud.sql.v1.ISqlInstancesListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | undefined, + {} | undefined, + ] + >; list( - request?: protos.google.cloud.sql.v1.ISqlInstancesListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request: protos.google.cloud.sql.v1.ISqlInstancesListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | null | undefined, + {} | null | undefined + >, + ): void; + list( + request: protos.google.cloud.sql.v1.ISqlInstancesListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | null | undefined, + {} | null | undefined + >, + ): void; + list( + request?: protos.google.cloud.sql.v1.ISqlInstancesListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IInstancesListResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IInstancesListResponse, - protos.google.cloud.sql.v1.ISqlInstancesListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IInstancesListResponse, + protos.google.cloud.sql.v1.ISqlInstancesListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all of the trusted Certificate Authorities (CAs) for the specified - * instance. There can be up to three CAs listed: the CA that was used to sign - * the certificate that is currently in use, a CA that has been added but not - * yet used to sign a certificate, and a CA used to sign a certificate that - * has previously rotated out. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.InstancesListServerCasResponse|InstancesListServerCasResponse}. - * Please see the {@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/sql_instances_service.list_server_cas.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ListServerCas_async - */ + /** + * Lists all of the trusted Certificate Authorities (CAs) for the specified + * instance. There can be up to three CAs listed: the CA that was used to sign + * the certificate that is currently in use, a CA that has been added but not + * yet used to sign a certificate, and a CA used to sign a certificate that + * has previously rotated out. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.InstancesListServerCasResponse|InstancesListServerCasResponse}. + * Please see the {@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/sql_instances_service.list_server_cas.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ListServerCas_async + */ listServerCas( - request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest | undefined, + {} | undefined, + ] + >; listServerCas( - request: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCas( - request: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCas( - request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listServerCas request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listServerCas response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listServerCas(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest|undefined, - {}|undefined - ]) => { - this._log.info('listServerCas response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listServerCas(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IInstancesListServerCasResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListServerCasRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listServerCas response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all versions of server certificates and certificate authorities (CAs) - * for the specified instance. There can be up to three sets of certs listed: - * the certificate that is currently in use, a future that has been added but - * not yet used to sign a certificate, and a certificate that has been rotated - * out. For instances not using Certificate Authority Service (CAS) server CA, - * use ListServerCas instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1.InstancesListServerCertificatesResponse|InstancesListServerCertificatesResponse}. - * Please see the {@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/sql_instances_service.list_server_certificates.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ListServerCertificates_async - */ + /** + * Lists all versions of server certificates and certificate authorities (CAs) + * for the specified instance. There can be up to three sets of certs listed: + * the certificate that is currently in use, a future that has been added but + * not yet used to sign a certificate, and a certificate that has been rotated + * out. For instances not using Certificate Authority Service (CAS) server CA, + * use ListServerCas instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1.InstancesListServerCertificatesResponse|InstancesListServerCertificatesResponse}. + * Please see the {@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/sql_instances_service.list_server_certificates.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ListServerCertificates_async + */ listServerCertificates( - request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ] + >; listServerCertificates( - request: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCertificates( - request: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCertificates( - request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listServerCertificates request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listServerCertificates response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listServerCertificates(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest|undefined, - {}|undefined - ]) => { - this._log.info('listServerCertificates response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listServerCertificates(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listServerCertificates response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all versions of EntraID certificates for the specified instance. - * There can be up to three sets of certificates listed: the certificate that - * is currently in use, a future that has been added but not yet used to sign - * a certificate, and a certificate that has been rotated out. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1.InstancesListEntraIdCertificatesResponse|InstancesListEntraIdCertificatesResponse}. - * Please see the {@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/sql_instances_service.list_entra_id_certificates.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ListEntraIdCertificates_async - */ + /** + * Lists all versions of EntraID certificates for the specified instance. + * There can be up to three sets of certificates listed: the certificate that + * is currently in use, a future that has been added but not yet used to sign + * a certificate, and a certificate that has been rotated out. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1.InstancesListEntraIdCertificatesResponse|InstancesListEntraIdCertificatesResponse}. + * Please see the {@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/sql_instances_service.list_entra_id_certificates.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ListEntraIdCertificates_async + */ listEntraIdCertificates( - request?: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ] + >; listEntraIdCertificates( - request: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listEntraIdCertificates( - request: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, - callback: Callback< - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, + callback: Callback< + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listEntraIdCertificates( - request?: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listEntraIdCertificates request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listEntraIdCertificates response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listEntraIdCertificates(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest|undefined, - {}|undefined - ]) => { - this._log.info('listEntraIdCertificates response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listEntraIdCertificates(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listEntraIdCertificates response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Partially updates settings of a Cloud SQL instance by merging the request - * with the current configuration. This method supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.patch.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Patch_async - */ + /** + * Partially updates settings of a Cloud SQL instance by merging the request + * with the current configuration. This method supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.patch.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Patch_async + */ patch( - request?: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ] + >; patch( - request: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | null | undefined, + {} | null | undefined + >, + ): void; patch( - request: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | null | undefined, + {} | null | undefined + >, + ): void; patch( - request?: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesPatchRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('patch request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('patch response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.patch(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPatchRequest|undefined, - {}|undefined - ]) => { - this._log.info('patch response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .patch(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ]) => { + this._log.info('patch response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Promotes the read replica instance to be an independent Cloud SQL - * primary instance. - * Using this operation might cause your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {boolean} request.failover - * Set to true to invoke a replica failover to the DR - * replica. As part of replica failover, the promote operation attempts - * to add the original primary instance as a replica of the promoted - * DR replica when the original primary instance comes back online. - * If set to false or not specified, then the original primary - * instance becomes an independent Cloud SQL primary 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.promote_replica.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_PromoteReplica_async - */ + /** + * Promotes the read replica instance to be an independent Cloud SQL + * primary instance. + * Using this operation might cause your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {boolean} request.failover + * Set to true to invoke a replica failover to the DR + * replica. As part of replica failover, the promote operation attempts + * to add the original primary instance as a replica of the promoted + * DR replica when the original primary instance comes back online. + * If set to false or not specified, then the original primary + * instance becomes an independent Cloud SQL primary 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.promote_replica.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_PromoteReplica_async + */ promoteReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest | undefined, + {} | undefined, + ] + >; promoteReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; promoteReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; promoteReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('promoteReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('promoteReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.promoteReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('promoteReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .promoteReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPromoteReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('promoteReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Switches over from the primary instance to the DR replica - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the replica. - * @param {google.protobuf.Duration} [request.dbTimeout] - * Optional. (MySQL and PostgreSQL only) Cloud SQL instance operations - * timeout, which is a sum of all database operations. Default value is 10 - * minutes and can be modified to a maximum value of 24 hours. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.switchover.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Switchover_async - */ + /** + * Switches over from the primary instance to the DR replica + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the replica. + * @param {google.protobuf.Duration} [request.dbTimeout] + * Optional. (MySQL and PostgreSQL only) Cloud SQL instance operations + * timeout, which is a sum of all database operations. Default value is 10 + * minutes and can be modified to a maximum value of 24 hours. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.switchover.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Switchover_async + */ switchover( - request?: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest | undefined, + {} | undefined, + ] + >; switchover( - request: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; switchover( - request: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; switchover( - request?: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('switchover request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('switchover response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.switchover(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest|undefined, - {}|undefined - ]) => { - this._log.info('switchover response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .switchover(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesSwitchoverRequest | undefined, + {} | undefined, + ]) => { + this._log.info('switchover response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all client certificates and generates a new server SSL certificate - * for the instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.SqlInstancesResetSslConfigRequest.ResetSslMode} [request.mode] - * Optional. Reset SSL mode to use. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.reset_ssl_config.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ResetSslConfig_async - */ + /** + * Deletes all client certificates and generates a new server SSL certificate + * for the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.SqlInstancesResetSslConfigRequest.ResetSslMode} [request.mode] + * Optional. Reset SSL mode to use. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.reset_ssl_config.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ResetSslConfig_async + */ resetSslConfig( - request?: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest | undefined, + {} | undefined, + ] + >; resetSslConfig( - request: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetSslConfig( - request: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetSslConfig( - request?: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('resetSslConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resetSslConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resetSslConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('resetSslConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resetSslConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesResetSslConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resetSslConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Restarts a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be restarted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.restart.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Restart_async - */ + /** + * Restarts a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be restarted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.restart.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Restart_async + */ restart( - request?: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | undefined, + {} | undefined, + ] + >; restart( - request: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | null | undefined, + {} | null | undefined + >, + ): void; restart( - request: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | null | undefined, + {} | null | undefined + >, + ): void; restart( - request?: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRestartRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('restart request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('restart response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.restart(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestartRequest|undefined, - {}|undefined - ]) => { - this._log.info('restart response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .restart(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestartRequest | undefined, + {} | undefined, + ]) => { + this._log.info('restart response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Restores a backup of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesRestoreBackupRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.restore_backup.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_RestoreBackup_async - */ + /** + * Restores a backup of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesRestoreBackupRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.restore_backup.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_RestoreBackup_async + */ restoreBackup( - request?: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest | undefined, + {} | undefined, + ] + >; restoreBackup( - request: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreBackup( - request: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreBackup( - request?: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('restoreBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('restoreBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.restoreBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('restoreBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .restoreBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRestoreBackupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('restoreBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the server certificate to one signed by the Certificate Authority - * (CA) version previously added with the addServerCA method. For instances - * that have enabled Certificate Authority Service (CAS) based server CA, - * use RotateServerCertificate to rotate the server certificate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesRotateServerCaRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.rotate_server_ca.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateServerCa_async - */ + /** + * Rotates the server certificate to one signed by the Certificate Authority + * (CA) version previously added with the addServerCA method. For instances + * that have enabled Certificate Authority Service (CAS) based server CA, + * use RotateServerCertificate to rotate the server certificate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesRotateServerCaRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.rotate_server_ca.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateServerCa_async + */ rotateServerCa( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest | undefined, + {} | undefined, + ] + >; rotateServerCa( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCa( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCa( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateServerCa request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateServerCa response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateServerCa(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateServerCa response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateServerCa(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateServerCa response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the server certificate version to one previously added with the - * addServerCertificate method. For instances not using Certificate Authority - * Service (CAS) server CA, use RotateServerCa instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesRotateServerCertificateRequest} [request.body] - * Optional. Rotate server certificate request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.rotate_server_certificate.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateServerCertificate_async - */ + /** + * Rotates the server certificate version to one previously added with the + * addServerCertificate method. For instances not using Certificate Authority + * Service (CAS) server CA, use RotateServerCa instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesRotateServerCertificateRequest} [request.body] + * Optional. Rotate server certificate request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.rotate_server_certificate.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateServerCertificate_async + */ rotateServerCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ] + >; rotateServerCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateServerCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateServerCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateServerCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateServerCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateServerCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateServerCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the server certificate version to one previously added with the - * addEntraIdCertificate method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesRotateEntraIdCertificateRequest} [request.body] - * Optional. Rotate Entra ID certificate request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.rotate_entra_id_certificate.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateEntraIdCertificate_async - */ + /** + * Rotates the server certificate version to one previously added with the + * addEntraIdCertificate method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesRotateEntraIdCertificateRequest} [request.body] + * Optional. Rotate Entra ID certificate request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.rotate_entra_id_certificate.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_RotateEntraIdCertificate_async + */ rotateEntraIdCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + >; rotateEntraIdCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateEntraIdCertificate( - request: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateEntraIdCertificate( - request?: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateEntraIdCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateEntraIdCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateEntraIdCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateEntraIdCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateEntraIdCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateEntraIdCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Starts the replication in the read replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.start_replica.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_StartReplica_async - */ + /** + * Starts the replication in the read replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.start_replica.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_StartReplica_async + */ startReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest | undefined, + {} | undefined, + ] + >; startReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('startReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('startReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.startReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('startReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .startReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesStartReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Stops the replication in the read replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.stop_replica.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_StopReplica_async - */ + /** + * Stops the replication in the read replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.stop_replica.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_StopReplica_async + */ stopReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest | undefined, + {} | undefined, + ] + >; stopReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; stopReplica( - request: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; stopReplica( - request?: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('stopReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('stopReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.stopReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('stopReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .stopReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesStopReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('stopReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Truncate MySQL general and slow query log tables - * MySQL only. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the Cloud SQL project. - * @param {google.cloud.sql.v1.InstancesTruncateLogRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.truncate_log.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_TruncateLog_async - */ + /** + * Truncate MySQL general and slow query log tables + * MySQL only. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the Cloud SQL project. + * @param {google.cloud.sql.v1.InstancesTruncateLogRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.truncate_log.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_TruncateLog_async + */ truncateLog( - request?: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest | undefined, + {} | undefined, + ] + >; truncateLog( - request: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): void; truncateLog( - request: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): void; truncateLog( - request?: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('truncateLog request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('truncateLog response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.truncateLog(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest|undefined, - {}|undefined - ]) => { - this._log.info('truncateLog response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .truncateLog(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesTruncateLogRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('truncateLog response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 settings of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.update.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_Update_async - */ + /** + * Updates settings of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.update.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_Update_async + */ update( - request?: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlInstancesUpdateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the Cloud SQL project. - * @param {google.cloud.sql.v1.SslCertsCreateEphemeralRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCert|SslCert}. - * Please see the {@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/sql_instances_service.create_ephemeral.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_CreateEphemeral_async - */ + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the Cloud SQL project. + * @param {google.cloud.sql.v1.SslCertsCreateEphemeralRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCert|SslCert}. + * Please see the {@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/sql_instances_service.create_ephemeral.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_CreateEphemeral_async + */ createEphemeral( - request?: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCert, + ( + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ] + >; createEphemeral( - request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISslCert, + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEphemeral( - request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISslCert, + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEphemeral( - request?: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISslCert, + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCert, + ( + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createEphemeral request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISslCert, + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createEphemeral response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createEphemeral(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest|undefined, - {}|undefined - ]) => { - this._log.info('createEphemeral response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createEphemeral(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISslCert, + ( + | protos.google.cloud.sql.v1.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEphemeral response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reschedules the maintenance on the given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequestBody} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.reschedule_maintenance.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_RescheduleMaintenance_async - */ + /** + * Reschedules the maintenance on the given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequestBody} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.reschedule_maintenance.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_RescheduleMaintenance_async + */ rescheduleMaintenance( - request?: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ] + >; rescheduleMaintenance( - request: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request?: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rescheduleMaintenance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rescheduleMaintenance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rescheduleMaintenance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('rescheduleMaintenance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rescheduleMaintenance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rescheduleMaintenance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Verify External primary instance external sync settings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {boolean} request.verifyConnectionOnly - * Flag to enable verifying connection only - * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode - * External sync mode - * @param {boolean} [request.verifyReplicationOnly] - * Optional. Flag to verify settings required by replication setup only - * @param {google.cloud.sql.v1.MySqlSyncConfig} [request.mysqlSyncConfig] - * Optional. MySQL-specific settings for start external sync. - * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] - * Optional. MigrationType configures the migration to use physical files or - * logical dump files. If not set, then the logical dump file configuration is - * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. - * @param {google.cloud.sql.v1.ExternalSyncParallelLevel} [request.syncParallelLevel] - * Optional. Parallel level for initial data sync. Only applicable for - * PostgreSQL. - * @param {number[]} [request.selectedObjects] - * Optional. Migrate only the specified objects from the source instance. If - * this field is empty, then migrate all objects. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse|SqlInstancesVerifyExternalSyncSettingsResponse}. - * Please see the {@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/sql_instances_service.verify_external_sync_settings.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_VerifyExternalSyncSettings_async - */ + /** + * Verify External primary instance external sync settings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {boolean} request.verifyConnectionOnly + * Flag to enable verifying connection only + * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode + * External sync mode + * @param {boolean} [request.verifyReplicationOnly] + * Optional. Flag to verify settings required by replication setup only + * @param {google.cloud.sql.v1.MySqlSyncConfig} [request.mysqlSyncConfig] + * Optional. MySQL-specific settings for start external sync. + * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] + * Optional. MigrationType configures the migration to use physical files or + * logical dump files. If not set, then the logical dump file configuration is + * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. + * @param {google.cloud.sql.v1.ExternalSyncParallelLevel} [request.syncParallelLevel] + * Optional. Parallel level for initial data sync. Only applicable for + * PostgreSQL. + * @param {number[]} [request.selectedObjects] + * Optional. Migrate only the specified objects from the source instance. If + * this field is empty, then migrate all objects. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse|SqlInstancesVerifyExternalSyncSettingsResponse}. + * Please see the {@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/sql_instances_service.verify_external_sync_settings.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_VerifyExternalSyncSettings_async + */ verifyExternalSyncSettings( - request?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ] + >; verifyExternalSyncSettings( - request: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; verifyExternalSyncSettings( - request: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; verifyExternalSyncSettings( - request?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('verifyExternalSyncSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('verifyExternalSyncSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.verifyExternalSyncSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('verifyExternalSyncSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .verifyExternalSyncSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('verifyExternalSyncSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Start External primary instance migration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode - * External sync mode. - * @param {boolean} request.skipVerification - * Whether to skip the verification step (VESS). - * @param {google.cloud.sql.v1.MySqlSyncConfig} request.mysqlSyncConfig - * MySQL-specific settings for start external sync. - * @param {google.cloud.sql.v1.ExternalSyncParallelLevel} [request.syncParallelLevel] - * Optional. Parallel level for initial data sync. Currently only applicable - * for MySQL. - * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] - * Optional. MigrationType configures the migration to use physical files or - * logical dump files. If not set, then the logical dump file configuration is - * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. - * @param {boolean} [request.replicaOverwriteEnabled] - * Optional. MySQL only. True if end-user has confirmed that this SES call - * will wipe replica databases overlapping with the proposed selected_objects. - * If this field is not set and there are both overlapping and additional - * databases proposed, an error 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 an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.start_external_sync.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_StartExternalSync_async - */ + /** + * Start External primary instance migration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode + * External sync mode. + * @param {boolean} request.skipVerification + * Whether to skip the verification step (VESS). + * @param {google.cloud.sql.v1.MySqlSyncConfig} request.mysqlSyncConfig + * MySQL-specific settings for start external sync. + * @param {google.cloud.sql.v1.ExternalSyncParallelLevel} [request.syncParallelLevel] + * Optional. Parallel level for initial data sync. Currently only applicable + * for MySQL. + * @param {google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] + * Optional. MigrationType configures the migration to use physical files or + * logical dump files. If not set, then the logical dump file configuration is + * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. + * @param {boolean} [request.replicaOverwriteEnabled] + * Optional. MySQL only. True if end-user has confirmed that this SES call + * will wipe replica databases overlapping with the proposed selected_objects. + * If this field is not set and there are both overlapping and additional + * databases proposed, an error 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 an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.start_external_sync.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_StartExternalSync_async + */ startExternalSync( - request?: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ] + >; startExternalSync( - request: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startExternalSync( - request: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startExternalSync( - request?: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('startExternalSync request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('startExternalSync response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.startExternalSync(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest|undefined, - {}|undefined - ]) => { - this._log.info('startExternalSync response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .startExternalSync(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startExternalSync response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Perform Disk Shrink on primary instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.PerformDiskShrinkContext} request.body - * Perform disk shrink context. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.perform_disk_shrink.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_PerformDiskShrink_async - */ + /** + * Perform Disk Shrink on primary instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.PerformDiskShrinkContext} request.body + * Perform disk shrink context. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.perform_disk_shrink.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_PerformDiskShrink_async + */ performDiskShrink( - request?: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ] + >; performDiskShrink( - request: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; performDiskShrink( - request: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; performDiskShrink( - request?: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('performDiskShrink request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('performDiskShrink response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.performDiskShrink(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest|undefined, - {}|undefined - ]) => { - this._log.info('performDiskShrink response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .performDiskShrink(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('performDiskShrink response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Disk Shrink Config for a given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.SqlInstancesGetDiskShrinkConfigResponse|SqlInstancesGetDiskShrinkConfigResponse}. - * Please see the {@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/sql_instances_service.get_disk_shrink_config.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_GetDiskShrinkConfig_async - */ + /** + * Get Disk Shrink Config for a given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.SqlInstancesGetDiskShrinkConfigResponse|SqlInstancesGetDiskShrinkConfigResponse}. + * Please see the {@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/sql_instances_service.get_disk_shrink_config.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_GetDiskShrinkConfig_async + */ getDiskShrinkConfig( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ] + >; getDiskShrinkConfig( - request: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDiskShrinkConfig( - request: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDiskShrinkConfig( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDiskShrinkConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDiskShrinkConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDiskShrinkConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDiskShrinkConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getDiskShrinkConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDiskShrinkConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reset Replica Size to primary instance disk size. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.reset_replica_size.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ResetReplicaSize_async - */ + /** + * Reset Replica Size to primary instance disk size. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.reset_replica_size.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ResetReplicaSize_async + */ resetReplicaSize( - request?: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ] + >; resetReplicaSize( - request: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetReplicaSize( - request: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetReplicaSize( - request?: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('resetReplicaSize request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resetReplicaSize response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resetReplicaSize(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest|undefined, - {}|undefined - ]) => { - this._log.info('resetReplicaSize response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resetReplicaSize(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resetReplicaSize response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Latest Recovery Time for a given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.protobuf.Timestamp} request.sourceInstanceDeletionTime - * The timestamp used to identify the time when the source instance is - * deleted. If this instance is deleted, then you must set the timestamp. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse|SqlInstancesGetLatestRecoveryTimeResponse}. - * Please see the {@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/sql_instances_service.get_latest_recovery_time.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_GetLatestRecoveryTime_async - */ + /** + * Get Latest Recovery Time for a given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.protobuf.Timestamp} request.sourceInstanceDeletionTime + * The timestamp used to identify the time when the source instance is + * deleted. If this instance is deleted, then you must set the timestamp. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse|SqlInstancesGetLatestRecoveryTimeResponse}. + * Please see the {@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/sql_instances_service.get_latest_recovery_time.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_GetLatestRecoveryTime_async + */ getLatestRecoveryTime( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ] + >; getLatestRecoveryTime( - request: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLatestRecoveryTime( - request: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLatestRecoveryTime( - request?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLatestRecoveryTime request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLatestRecoveryTime response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLatestRecoveryTime(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLatestRecoveryTime response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getLatestRecoveryTime(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLatestRecoveryTime response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Execute SQL statements. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Database instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.ExecuteSqlPayload} request.body - * The request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse|SqlInstancesExecuteSqlResponse}. - * Please see the {@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/sql_instances_service.execute_sql.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ExecuteSql_async - */ + /** + * Execute SQL statements. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Database instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.ExecuteSqlPayload} request.body + * The request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse|SqlInstancesExecuteSqlResponse}. + * Please see the {@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/sql_instances_service.execute_sql.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ExecuteSql_async + */ executeSql( - request?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest | undefined, + {} | undefined, + ] + >; executeSql( - request: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeSql( - request: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeSql( - request?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeSql request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeSql response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeSql(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeSql response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .executeSql(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse, + protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlRequest | undefined, + {} | undefined, + ]) => { + this._log.info('executeSql response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Acquire a lease for the setup of SQL Server Reporting Services (SSRS). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This doesn't include the project ID. It's - * composed of lowercase letters, numbers, and hyphens, and it must start with - * a letter. The total length must be 98 characters or less (Example: - * instance-id). - * @param {string} request.project - * Required. Project ID of the project that contains the instance (Example: - * project-id). - * @param {google.cloud.sql.v1.InstancesAcquireSsrsLeaseRequest} request.body - * Required. The request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse|SqlInstancesAcquireSsrsLeaseResponse}. - * Please see the {@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/sql_instances_service.acquire_ssrs_lease.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_AcquireSsrsLease_async - */ + /** + * Acquire a lease for the setup of SQL Server Reporting Services (SSRS). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This doesn't include the project ID. It's + * composed of lowercase letters, numbers, and hyphens, and it must start with + * a letter. The total length must be 98 characters or less (Example: + * instance-id). + * @param {string} request.project + * Required. Project ID of the project that contains the instance (Example: + * project-id). + * @param {google.cloud.sql.v1.InstancesAcquireSsrsLeaseRequest} request.body + * Required. The request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse|SqlInstancesAcquireSsrsLeaseResponse}. + * Please see the {@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/sql_instances_service.acquire_ssrs_lease.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_AcquireSsrsLease_async + */ acquireSsrsLease( - request?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + >; acquireSsrsLease( - request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acquireSsrsLease( - request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acquireSsrsLease( - request?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('acquireSsrsLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('acquireSsrsLease response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.acquireSsrsLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('acquireSsrsLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .acquireSsrsLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('acquireSsrsLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Release a lease for the setup of SQL Server Reporting Services (SSRS). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. The Cloud SQL instance ID. This doesn't include the project ID. - * The instance ID contains lowercase letters, numbers, and hyphens, and it - * must start with a letter. This ID can have a maximum length of 98 - * characters. - * @param {string} request.project - * Required. The project ID that contains 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.sql.v1.SqlInstancesReleaseSsrsLeaseResponse|SqlInstancesReleaseSsrsLeaseResponse}. - * Please see the {@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/sql_instances_service.release_ssrs_lease.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_ReleaseSsrsLease_async - */ + /** + * Release a lease for the setup of SQL Server Reporting Services (SSRS). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. The Cloud SQL instance ID. This doesn't include the project ID. + * The instance ID contains lowercase letters, numbers, and hyphens, and it + * must start with a letter. This ID can have a maximum length of 98 + * characters. + * @param {string} request.project + * Required. The project ID that contains 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.sql.v1.SqlInstancesReleaseSsrsLeaseResponse|SqlInstancesReleaseSsrsLeaseResponse}. + * Please see the {@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/sql_instances_service.release_ssrs_lease.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_ReleaseSsrsLease_async + */ releaseSsrsLease( - request?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + >; releaseSsrsLease( - request: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; releaseSsrsLease( - request: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; releaseSsrsLease( - request?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('releaseSsrsLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('releaseSsrsLease response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.releaseSsrsLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('releaseSsrsLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .releaseSsrsLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('releaseSsrsLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Execute MVU Pre-checks - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.InstancesPreCheckMajorVersionUpgradeRequest} request.body - * Required. The context for request to perform the pre-check major version - * upgrade operation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.pre_check_major_version_upgrade.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_PreCheckMajorVersionUpgrade_async - */ + /** + * Execute MVU Pre-checks + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.InstancesPreCheckMajorVersionUpgradeRequest} request.body + * Required. The context for request to perform the pre-check major version + * upgrade operation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.pre_check_major_version_upgrade.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_PreCheckMajorVersionUpgrade_async + */ preCheckMajorVersionUpgrade( - request?: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ] + >; preCheckMajorVersionUpgrade( - request: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; preCheckMajorVersionUpgrade( - request: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; preCheckMajorVersionUpgrade( - request?: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('preCheckMajorVersionUpgrade request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('preCheckMajorVersionUpgrade response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.preCheckMajorVersionUpgrade(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, - {}|undefined - ]) => { - this._log.info('preCheckMajorVersionUpgrade response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .preCheckMajorVersionUpgrade(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('preCheckMajorVersionUpgrade response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Point in time restore for an instance managed by Google Cloud Backup and - * Disaster Recovery. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where you created this instance. - * Format: projects/{project} - * @param {google.cloud.sql.v1.PointInTimeRestoreContext} request.context - * Required. The context for request to perform a PITR on a Google Cloud - * Backup and Disaster Recovery managed 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_instances_service.point_in_time_restore.js - * region_tag:sqladmin_v1_generated_SqlInstancesService_PointInTimeRestore_async - */ + /** + * Point in time restore for an instance managed by Google Cloud Backup and + * Disaster Recovery. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where you created this instance. + * Format: projects/{project} + * @param {google.cloud.sql.v1.PointInTimeRestoreContext} request.context + * Required. The context for request to perform a PITR on a Google Cloud + * Backup and Disaster Recovery managed 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_instances_service.point_in_time_restore.js + * region_tag:sqladmin_v1_generated_SqlInstancesService_PointInTimeRestore_async + */ pointInTimeRestore( - request?: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ] + >; pointInTimeRestore( - request: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): void; pointInTimeRestore( - request: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): void; pointInTimeRestore( - request?: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('pointInTimeRestore request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('pointInTimeRestore response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.pointInTimeRestore(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest|undefined, - {}|undefined - ]) => { - this._log.info('pointInTimeRestore response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .pointInTimeRestore(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + ( + | protos.google.cloud.sql.v1.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('pointInTimeRestore response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -4712,12 +6642,11 @@ export class SqlInstancesServiceClient { | 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. @@ -4750,7 +6679,7 @@ export class SqlInstancesServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -4769,7 +6698,13 @@ export class SqlInstancesServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,location:string,backupvault:string,datasource:string,backup:string) { + backupPath( + project: string, + location: string, + backupvault: string, + datasource: string, + backup: string, + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, location: location, @@ -4841,7 +6776,7 @@ export class SqlInstancesServiceClient { * @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, @@ -4878,13 +6813,15 @@ export class SqlInstancesServiceClient { */ close(): Promise { if (this.sqlInstancesServiceStub && !this._terminated) { - return this.sqlInstancesServiceStub.then(stub => { + return this.sqlInstancesServiceStub.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-sql/src/v1/sql_operations_service_client.ts b/packages/google-cloud-sql/src/v1/sql_operations_service_client.ts index d027e27c654b..4d9599d37c13 100644 --- a/packages/google-cloud-sql/src/v1/sql_operations_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_operations_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlOperationsServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlOperationsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlOperationsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlOperationsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlOperationsServiceClient. @@ -101,21 +108,42 @@ export class SqlOperationsServiceClient { * const client = new SqlOperationsServiceClient({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 SqlOperationsServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlOperationsServiceClient { 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 +182,11 @@ export class SqlOperationsServiceClient { } 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,14 +208,17 @@ export class SqlOperationsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlOperationsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlOperationsService', + 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 @@ -222,36 +249,40 @@ export class SqlOperationsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlOperationsService. this.sqlOperationsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlOperationsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlOperationsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlOperationsService, - 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 sqlOperationsServiceStubMethods = - ['get', 'list', 'cancel']; + const sqlOperationsServiceStubMethods = ['get', 'list', 'cancel']; for (const methodName of sqlOperationsServiceStubMethods) { const callPromise = this.sqlOperationsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlOperationsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlOperationsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlOperationsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlOperationsServiceClient { * 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; @@ -334,304 +378,406 @@ export class SqlOperationsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves an instance operation that has been performed on an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.operation - * Required. Instance operation ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_operations_service.get.js - * region_tag:sqladmin_v1_generated_SqlOperationsService_Get_async - */ + /** + * Retrieves an instance operation that has been performed on an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Required. Instance operation ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_operations_service.get.js + * region_tag:sqladmin_v1_generated_SqlOperationsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlOperationsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'operation': request.operation ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + operation: request.operation ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlOperationsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlOperationsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all instance operations that have been performed on the given Cloud - * SQL instance in the reverse chronological order of the start time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {number} request.maxResults - * Maximum number of operations per response. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.OperationsListResponse|OperationsListResponse}. - * Please see the {@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/sql_operations_service.list.js - * region_tag:sqladmin_v1_generated_SqlOperationsService_List_async - */ + /** + * Lists all instance operations that have been performed on the given Cloud + * SQL instance in the reverse chronological order of the start time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {number} request.maxResults + * Maximum number of operations per response. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.OperationsListResponse|OperationsListResponse}. + * Please see the {@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/sql_operations_service.list.js + * region_tag:sqladmin_v1_generated_SqlOperationsService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlOperationsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlOperationsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlOperationsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlOperationsListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlOperationsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlOperationsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperationsListResponse, + | protos.google.cloud.sql.v1.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperationsListResponse, - protos.google.cloud.sql.v1.ISqlOperationsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperationsListResponse, + protos.google.cloud.sql.v1.ISqlOperationsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Cancels an instance operation that has been performed on an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.operation - * Instance operation ID. - * @param {string} request.project - * Project ID of the project that contains 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.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/sql_operations_service.cancel.js - * region_tag:sqladmin_v1_generated_SqlOperationsService_Cancel_async - */ + /** + * Cancels an instance operation that has been performed on an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Instance operation ID. + * @param {string} request.project + * Project ID of the project that contains 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.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/sql_operations_service.cancel.js + * region_tag:sqladmin_v1_generated_SqlOperationsService_Cancel_async + */ cancel( - request?: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | undefined, + {} | undefined, + ] + >; cancel( - request: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | null | undefined, + {} | null | undefined + >, + ): void; cancel( - request: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | null | undefined, + {} | null | undefined + >, + ): void; cancel( - request?: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlOperationsCancelRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'operation': request.operation ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + operation: request.operation ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('cancel request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.sql.v1.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('cancel response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.cancel(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1.ISqlOperationsCancelRequest|undefined, - {}|undefined - ]) => { - this._log.info('cancel response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .cancel(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1.ISqlOperationsCancelRequest | undefined, + {} | undefined, + ]) => { + this._log.info('cancel response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -666,12 +812,11 @@ export class SqlOperationsServiceClient { | 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. @@ -704,7 +849,7 @@ export class SqlOperationsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -720,7 +865,7 @@ export class SqlOperationsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -757,13 +902,15 @@ export class SqlOperationsServiceClient { */ close(): Promise { if (this.sqlOperationsServiceStub && !this._terminated) { - return this.sqlOperationsServiceStub.then(stub => { + return this.sqlOperationsServiceStub.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-sql/src/v1/sql_ssl_certs_service_client.ts b/packages/google-cloud-sql/src/v1/sql_ssl_certs_service_client.ts index df2bb53abd2d..e820b8c0dff9 100644 --- a/packages/google-cloud-sql/src/v1/sql_ssl_certs_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_ssl_certs_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlSslCertsServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlSslCertsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlSslCertsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlSslCertsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlSslCertsServiceClient. @@ -101,21 +108,42 @@ export class SqlSslCertsServiceClient { * const client = new SqlSslCertsServiceClient({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 SqlSslCertsServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlSslCertsServiceClient { 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 +182,11 @@ export class SqlSslCertsServiceClient { } 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,14 +208,17 @@ export class SqlSslCertsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlSslCertsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlSslCertsService', + 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 @@ -222,36 +249,40 @@ export class SqlSslCertsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlSslCertsService. this.sqlSslCertsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlSslCertsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlSslCertsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlSslCertsService, - 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 sqlSslCertsServiceStubMethods = - ['delete', 'get', 'insert', 'list']; + const sqlSslCertsServiceStubMethods = ['delete', 'get', 'insert', 'list']; for (const methodName of sqlSslCertsServiceStubMethods) { const callPromise = this.sqlSslCertsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlSslCertsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlSslCertsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlSslCertsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlSslCertsServiceClient { * 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; @@ -334,408 +378,536 @@ export class SqlSslCertsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes the SSL certificate. For First Generation instances, the - * certificate remains valid until the instance is restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.sha1Fingerprint - * Sha1 FingerPrint. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_ssl_certs_service.delete.js - * region_tag:sqladmin_v1_generated_SqlSslCertsService_Delete_async - */ + /** + * Deletes the SSL certificate. For First Generation instances, the + * certificate remains valid until the instance is restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.sha1Fingerprint + * Sha1 FingerPrint. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_ssl_certs_service.delete.js + * region_tag:sqladmin_v1_generated_SqlSslCertsService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'sha1_fingerprint': request.sha1Fingerprint ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + sha1_fingerprint: request.sha1Fingerprint ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + | protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a particular SSL certificate. Does not include the private key - * (required for usage). The private key must be saved from the response to - * initial creation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.sha1Fingerprint - * Sha1 FingerPrint. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCert|SslCert}. - * Please see the {@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/sql_ssl_certs_service.get.js - * region_tag:sqladmin_v1_generated_SqlSslCertsService_Get_async - */ + /** + * Retrieves a particular SSL certificate. Does not include the private key + * (required for usage). The private key must be saved from the response to + * initial creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.sha1Fingerprint + * Sha1 FingerPrint. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCert|SslCert}. + * Please see the {@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/sql_ssl_certs_service.get.js + * region_tag:sqladmin_v1_generated_SqlSslCertsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlSslCertsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'sha1_fingerprint': request.sha1Fingerprint ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + sha1_fingerprint: request.sha1Fingerprint ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISslCert, - protos.google.cloud.sql.v1.ISqlSslCertsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISslCert, + protos.google.cloud.sql.v1.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 SSL certificate and returns it along with the private key and - * server certificate authority. The new certificate will not be usable until - * the instance is restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.SslCertsInsertRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCertsInsertResponse|SslCertsInsertResponse}. - * Please see the {@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/sql_ssl_certs_service.insert.js - * region_tag:sqladmin_v1_generated_SqlSslCertsService_Insert_async - */ + /** + * Creates an SSL certificate and returns it along with the private key and + * server certificate authority. The new certificate will not be usable until + * the instance is restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.SslCertsInsertRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.SslCertsInsertResponse|SslCertsInsertResponse}. + * Please see the {@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/sql_ssl_certs_service.insert.js + * region_tag:sqladmin_v1_generated_SqlSslCertsService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + | protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISslCertsInsertResponse, - protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISslCertsInsertResponse, + protos.google.cloud.sql.v1.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all of the current SSL certificates for the instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.SslCertsListResponse|SslCertsListResponse}. - * Please see the {@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/sql_ssl_certs_service.list.js - * region_tag:sqladmin_v1_generated_SqlSslCertsService_List_async - */ + /** + * Lists all of the current SSL certificates for the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.SslCertsListResponse|SslCertsListResponse}. + * Please see the {@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/sql_ssl_certs_service.list.js + * region_tag:sqladmin_v1_generated_SqlSslCertsService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, - callback: Callback< - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, + callback: Callback< + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlSslCertsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ISslCertsListResponse, - protos.google.cloud.sql.v1.ISqlSslCertsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ISslCertsListResponse, + protos.google.cloud.sql.v1.ISqlSslCertsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -770,12 +942,11 @@ export class SqlSslCertsServiceClient { | 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. @@ -808,7 +979,7 @@ export class SqlSslCertsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -824,7 +995,7 @@ export class SqlSslCertsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -861,13 +1032,15 @@ export class SqlSslCertsServiceClient { */ close(): Promise { if (this.sqlSslCertsServiceStub && !this._terminated) { - return this.sqlSslCertsServiceStub.then(stub => { + return this.sqlSslCertsServiceStub.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-sql/src/v1/sql_tiers_service_client.ts b/packages/google-cloud-sql/src/v1/sql_tiers_service_client.ts index f8c5bac50336..559916f53617 100644 --- a/packages/google-cloud-sql/src/v1/sql_tiers_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_tiers_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlTiersServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlTiersServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlTiersServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlTiersServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlTiersServiceClient. @@ -101,21 +108,42 @@ export class SqlTiersServiceClient { * const client = new SqlTiersServiceClient({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 SqlTiersServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlTiersServiceClient { 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 +182,11 @@ export class SqlTiersServiceClient { } 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,14 +208,17 @@ export class SqlTiersServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlTiersService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlTiersService', + 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 @@ -222,36 +249,40 @@ export class SqlTiersServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlTiersService. this.sqlTiersServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlTiersService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlTiersService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlTiersService, - 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 sqlTiersServiceStubMethods = - ['list']; + const sqlTiersServiceStubMethods = ['list']; for (const methodName of sqlTiersServiceStubMethods) { const callPromise = this.sqlTiersServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlTiersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlTiersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlTiersServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlTiersServiceClient { * 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; @@ -334,104 +378,134 @@ export class SqlTiersServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Lists all available machine types (tiers) for Cloud SQL, for example, - * `db-custom-1-3840`. For more information, see - * https://cloud.google.com/sql/pricing. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.project - * Project ID of the project for which to list tiers. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.TiersListResponse|TiersListResponse}. - * Please see the {@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/sql_tiers_service.list.js - * region_tag:sqladmin_v1_generated_SqlTiersService_List_async - */ + /** + * Lists all available machine types (tiers) for Cloud SQL, for example, + * `db-custom-1-3840`. For more information, see + * https://cloud.google.com/sql/pricing. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID of the project for which to list tiers. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.TiersListResponse|TiersListResponse}. + * Please see the {@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/sql_tiers_service.list.js + * region_tag:sqladmin_v1_generated_SqlTiersService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlTiersListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlTiersListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlTiersListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlTiersListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlTiersListRequest, - callback: Callback< - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlTiersListRequest, + callback: Callback< + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlTiersListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlTiersListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.ITiersListResponse, - protos.google.cloud.sql.v1.ISqlTiersListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.ITiersListResponse, + protos.google.cloud.sql.v1.ISqlTiersListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -466,12 +540,11 @@ export class SqlTiersServiceClient { | 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. @@ -504,7 +577,7 @@ export class SqlTiersServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -520,7 +593,7 @@ export class SqlTiersServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -557,13 +630,15 @@ export class SqlTiersServiceClient { */ close(): Promise { if (this.sqlTiersServiceStub && !this._terminated) { - return this.sqlTiersServiceStub.then(stub => { + return this.sqlTiersServiceStub.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-sql/src/v1/sql_users_service_client.ts b/packages/google-cloud-sql/src/v1/sql_users_service_client.ts index 9550f405ca02..4ef6422ba951 100644 --- a/packages/google-cloud-sql/src/v1/sql_users_service_client.ts +++ b/packages/google-cloud-sql/src/v1/sql_users_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlUsersServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlUsersServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlUsersServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlUsersServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlUsersServiceClient. @@ -101,21 +108,42 @@ export class SqlUsersServiceClient { * const client = new SqlUsersServiceClient({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 SqlUsersServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlUsersServiceClient { 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 +182,11 @@ export class SqlUsersServiceClient { } 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,14 +208,17 @@ export class SqlUsersServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1.SqlUsersService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1.SqlUsersService', + 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 @@ -222,36 +249,46 @@ export class SqlUsersServiceClient { // Put together the "service stub" for // google.cloud.sql.v1.SqlUsersService. this.sqlUsersServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1.SqlUsersService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1.SqlUsersService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1.SqlUsersService, - 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 sqlUsersServiceStubMethods = - ['delete', 'get', 'insert', 'list', 'update']; + const sqlUsersServiceStubMethods = [ + 'delete', + 'get', + 'insert', + 'list', + 'update', + ]; for (const methodName of sqlUsersServiceStubMethods) { const callPromise = this.sqlUsersServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +303,14 @@ export class SqlUsersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +321,14 @@ export class SqlUsersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +361,7 @@ export class SqlUsersServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +371,9 @@ export class SqlUsersServiceClient { * 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; @@ -334,515 +384,665 @@ export class SqlUsersServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes a user from a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.host - * Host of the user in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * Name of the user in the instance. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.Operation|Operation}. - * Please see the {@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/sql_users_service.delete.js - * region_tag:sqladmin_v1_generated_SqlUsersService_Delete_async - */ + /** + * Deletes a user from a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.host + * Host of the user in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * Name of the user in the instance. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.Operation|Operation}. + * Please see the {@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/sql_users_service.delete.js + * region_tag:sqladmin_v1_generated_SqlUsersService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlUsersDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a user. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * User of the instance. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.host - * Host of a user of 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.sql.v1.User|User}. - * Please see the {@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/sql_users_service.get.js - * region_tag:sqladmin_v1_generated_SqlUsersService_Get_async - */ + /** + * Retrieves a resource containing information about a user. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * User of the instance. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.host + * Host of a user of 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.sql.v1.User|User}. + * Please see the {@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/sql_users_service.get.js + * region_tag:sqladmin_v1_generated_SqlUsersService_Get_async + */ get( - request?: protos.google.cloud.sql.v1.ISqlUsersGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlUsersGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1.ISqlUsersGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1.ISqlUsersGetRequest, - callback: Callback< - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersGetRequest, + callback: Callback< + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1.ISqlUsersGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlUsersGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IUser, - protos.google.cloud.sql.v1.ISqlUsersGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IUser, + protos.google.cloud.sql.v1.ISqlUsersGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 user in a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1.User} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_users_service.insert.js - * region_tag:sqladmin_v1_generated_SqlUsersService_Insert_async - */ + /** + * Creates a new user in a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1.User} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_users_service.insert.js + * region_tag:sqladmin_v1_generated_SqlUsersService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlUsersInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 users in the specified Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1.UsersListResponse|UsersListResponse}. - * Please see the {@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/sql_users_service.list.js - * region_tag:sqladmin_v1_generated_SqlUsersService_List_async - */ + /** + * Lists users in the specified Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1.UsersListResponse|UsersListResponse}. + * Please see the {@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/sql_users_service.list.js + * region_tag:sqladmin_v1_generated_SqlUsersService_List_async + */ list( - request?: protos.google.cloud.sql.v1.ISqlUsersListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlUsersListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1.ISqlUsersListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1.ISqlUsersListRequest, - callback: Callback< - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersListRequest, + callback: Callback< + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1.ISqlUsersListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlUsersListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IUsersListResponse, - protos.google.cloud.sql.v1.ISqlUsersListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IUsersListResponse, + protos.google.cloud.sql.v1.ISqlUsersListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 an existing user in a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.host] - * Optional. Host of the user in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * Name of the user in the instance. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string[]} [request.databaseRoles] - * Optional. List of database roles to grant to the user. body.database_roles - * will be ignored for update request. - * @param {boolean} [request.revokeExistingRoles] - * Optional. Specifies whether to revoke existing roles that are not present - * in the `database_roles` field. If `false` or unset, the database roles - * specified in `database_roles` are added to the user's existing roles. - * @param {google.cloud.sql.v1.User} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. - * Please see the {@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/sql_users_service.update.js - * region_tag:sqladmin_v1_generated_SqlUsersService_Update_async - */ + /** + * Updates an existing user in a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.host] + * Optional. Host of the user in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * Name of the user in the instance. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string[]} [request.databaseRoles] + * Optional. List of database roles to grant to the user. body.database_roles + * will be ignored for update request. + * @param {boolean} [request.revokeExistingRoles] + * Optional. Specifies whether to revoke existing roles that are not present + * in the `database_roles` field. If `false` or unset, the database roles + * specified in `database_roles` are added to the user's existing roles. + * @param {google.cloud.sql.v1.User} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1.Operation|Operation}. + * Please see the {@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/sql_users_service.update.js + * region_tag:sqladmin_v1_generated_SqlUsersService_Update_async + */ update( - request?: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1.ISqlUsersUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1.IOperation, - protos.google.cloud.sql.v1.ISqlUsersUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1.IOperation, + protos.google.cloud.sql.v1.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -877,12 +1077,11 @@ export class SqlUsersServiceClient { | 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. @@ -915,7 +1114,7 @@ export class SqlUsersServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -931,7 +1130,7 @@ export class SqlUsersServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -968,13 +1167,15 @@ export class SqlUsersServiceClient { */ close(): Promise { if (this.sqlUsersServiceStub && !this._terminated) { - return this.sqlUsersServiceStub.then(stub => { + return this.sqlUsersServiceStub.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-sql/src/v1beta4/index.ts b/packages/google-cloud-sql/src/v1beta4/index.ts index c1b5dcdaf6e0..d8f42f199ca2 100644 --- a/packages/google-cloud-sql/src/v1beta4/index.ts +++ b/packages/google-cloud-sql/src/v1beta4/index.ts @@ -16,14 +16,14 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {SqlBackupRunsServiceClient} from './sql_backup_runs_service_client'; -export {SqlBackupsServiceClient} from './sql_backups_service_client'; -export {SqlConnectServiceClient} from './sql_connect_service_client'; -export {SqlDatabasesServiceClient} from './sql_databases_service_client'; -export {SqlFlagsServiceClient} from './sql_flags_service_client'; - -export {SqlInstancesServiceClient} from './sql_instances_service_client'; -export {SqlOperationsServiceClient} from './sql_operations_service_client'; -export {SqlSslCertsServiceClient} from './sql_ssl_certs_service_client'; -export {SqlTiersServiceClient} from './sql_tiers_service_client'; -export {SqlUsersServiceClient} from './sql_users_service_client'; +export { SqlBackupRunsServiceClient } from './sql_backup_runs_service_client'; +export { SqlBackupsServiceClient } from './sql_backups_service_client'; +export { SqlConnectServiceClient } from './sql_connect_service_client'; +export { SqlDatabasesServiceClient } from './sql_databases_service_client'; +export { SqlFlagsServiceClient } from './sql_flags_service_client'; +export { SqlIamPoliciesServiceClient } from './sql_iam_policies_service_client'; +export { SqlInstancesServiceClient } from './sql_instances_service_client'; +export { SqlOperationsServiceClient } from './sql_operations_service_client'; +export { SqlSslCertsServiceClient } from './sql_ssl_certs_service_client'; +export { SqlTiersServiceClient } from './sql_tiers_service_client'; +export { SqlUsersServiceClient } from './sql_users_service_client'; diff --git a/packages/google-cloud-sql/src/v1beta4/sql_backup_runs_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_backup_runs_service_client.ts index 56b0124a7c70..1d8a6b7aca1a 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_backup_runs_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_backup_runs_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlBackupRunsServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlBackupRunsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlBackupRunsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlBackupRunsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlBackupRunsServiceClient. @@ -100,21 +107,42 @@ export class SqlBackupRunsServiceClient { * const client = new SqlBackupRunsServiceClient({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 SqlBackupRunsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlBackupRunsServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlBackupRunsServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlBackupRunsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlBackupRunsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlBackupRunsService', + 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 @@ -224,36 +251,40 @@ export class SqlBackupRunsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlBackupRunsService. this.sqlBackupRunsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlBackupRunsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlBackupRunsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlBackupRunsService, - 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 sqlBackupRunsServiceStubMethods = - ['delete', 'get', 'insert', 'list']; + const sqlBackupRunsServiceStubMethods = ['delete', 'get', 'insert', 'list']; for (const methodName of sqlBackupRunsServiceStubMethods) { const callPromise = this.sqlBackupRunsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +299,14 @@ export class SqlBackupRunsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +317,14 @@ export class SqlBackupRunsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +357,7 @@ export class SqlBackupRunsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +367,9 @@ export class SqlBackupRunsServiceClient { * 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; @@ -336,413 +380,579 @@ export class SqlBackupRunsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes the backup taken by a backup run. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.id - * The ID of the backup run to delete. To find a backup run ID, use the - * [list](https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/backupRuns/list) - * method. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backup_runs_service.delete.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Delete_async - */ + /** + * Deletes the backup taken by a backup run. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.id + * The ID of the backup run to delete. To find a backup run ID, use the + * [list](https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/backupRuns/list) + * method. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backup_runs_service.delete.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'id': request.id?.toString() ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + id: request.id?.toString() ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsDeleteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a backup run. - * - * @param {Object} request - * The request object that will be sent. - * @param {number} request.id - * The ID of this backup run. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.BackupRun|BackupRun}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backup_runs_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Get_async - */ + /** + * Retrieves a resource containing information about a backup run. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.id + * The ID of this backup run. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.BackupRun|BackupRun}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backup_runs_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackupRun, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackupRun, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackupRun, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IBackupRun, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackupRun, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'id': request.id?.toString() ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + id: request.id?.toString() ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IBackupRun, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IBackupRun, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IBackupRun, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 backup run on demand. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.BackupRun} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backup_runs_service.insert.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Insert_async - */ + /** + * Creates a new backup run on demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.BackupRun} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backup_runs_service.insert.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsInsertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all backup runs associated with the project or a given instance and - * configuration in the reverse chronological order of the backup initiation - * time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID, or "-" for all instances. This does not include - * the project ID. - * @param {number} request.maxResults - * Maximum number of backup runs per response. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.BackupRunsListResponse|BackupRunsListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backup_runs_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_List_async - */ + /** + * Lists all backup runs associated with the project or a given instance and + * configuration in the reverse chronological order of the backup initiation + * time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID, or "-" for all instances. This does not include + * the project ID. + * @param {number} request.maxResults + * Maximum number of backup runs per response. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.BackupRunsListResponse|BackupRunsListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backup_runs_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupRunsService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, - protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IBackupRunsListResponse, + protos.google.cloud.sql.v1beta4.ISqlBackupRunsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -777,12 +987,11 @@ export class SqlBackupRunsServiceClient { | 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. @@ -815,7 +1024,7 @@ export class SqlBackupRunsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -831,7 +1040,7 @@ export class SqlBackupRunsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -866,7 +1075,7 @@ export class SqlBackupRunsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -891,13 +1100,15 @@ export class SqlBackupRunsServiceClient { */ close(): Promise { if (this.sqlBackupRunsServiceStub && !this._terminated) { - return this.sqlBackupRunsServiceStub.then(stub => { + return this.sqlBackupRunsServiceStub.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-sql/src/v1beta4/sql_backups_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_backups_service_client.ts index 21c870f5d116..8c51bd7530ed 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_backups_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_backups_service_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 @@ -43,7 +52,7 @@ export class SqlBackupsServiceClient { 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('sql'); @@ -56,10 +65,10 @@ export class SqlBackupsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlBackupsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlBackupsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlBackupsServiceClient. @@ -100,21 +109,42 @@ export class SqlBackupsServiceClient { * const client = new SqlBackupsServiceClient({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 SqlBackupsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +169,7 @@ export class SqlBackupsServiceClient { 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; @@ -153,15 +183,11 @@ export class SqlBackupsServiceClient { } 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 { @@ -183,10 +209,10 @@ export class SqlBackupsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -194,14 +220,20 @@ export class SqlBackupsServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlBackupsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlBackupsService', + 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 @@ -232,37 +264,46 @@ export class SqlBackupsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlBackupsService. this.sqlBackupsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlBackupsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlBackupsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlBackupsService, - 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 sqlBackupsServiceStubMethods = - ['createBackup', 'getBackup', 'listBackups', 'updateBackup', 'deleteBackup']; + const sqlBackupsServiceStubMethods = [ + 'createBackup', + 'getBackup', + 'listBackups', + 'updateBackup', + 'deleteBackup', + ]; for (const methodName of sqlBackupsServiceStubMethods) { const callPromise = this.sqlBackupsServiceStub.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; @@ -277,8 +318,14 @@ export class SqlBackupsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -289,8 +336,14 @@ export class SqlBackupsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -323,7 +376,7 @@ export class SqlBackupsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -333,8 +386,9 @@ export class SqlBackupsServiceClient { * 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; @@ -345,490 +399,641 @@ export class SqlBackupsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a backup for a Cloud SQL instance. This API can be used only to - * create on-demand backups. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where this backup is created. - * Format: projects/{project} - * @param {google.cloud.sql.v1beta4.Backup} request.backup - * Required. The Backup to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backups_service.create_backup.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_CreateBackup_async - */ + /** + * Creates a backup for a Cloud SQL instance. This API can be used only to + * create on-demand backups. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where this backup is created. + * Format: projects/{project} + * @param {google.cloud.sql.v1beta4.Backup} request.backup + * Required. The Backup to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backups_service.create_backup.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_CreateBackup_async + */ createBackup( - request?: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | undefined, + {} | undefined, + ] + >; createBackup( - request: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; createBackup( - request?: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ICreateBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ICreateBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ICreateBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('createBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ICreateBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the backup to retrieve. - * Format: projects/{project}/backups/{backup} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.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/v1beta4/sql_backups_service.get_backup.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_GetBackup_async - */ + /** + * Retrieves a resource containing information about a backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the backup to retrieve. + * Format: projects/{project}/backups/{backup} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.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/v1beta4/sql_backups_service.get_backup.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_GetBackup_async + */ getBackup( - request?: protos.google.cloud.sql.v1beta4.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.IGetBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.IGetBackupRequest | undefined, + {} | undefined, + ] + >; getBackup( - request: protos.google.cloud.sql.v1beta4.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request: protos.google.cloud.sql.v1beta4.IGetBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGetBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; getBackup( - request?: protos.google.cloud.sql.v1beta4.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.sql.v1beta4.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.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.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.IGetBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.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.sql.v1beta4.IBackup, - protos.google.cloud.sql.v1beta4.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.sql.v1beta4.IBackup, + protos.google.cloud.sql.v1beta4.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; }); } -/** - * Updates the retention period and the description of the backup. You can use - * this API to update final backups only. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.sql.v1beta4.Backup} request.backup - * Required. The backup to update. - * The backup’s `name` field is used to identify the backup to update. - * Format: projects/{project}/backups/{backup} - * @param {google.protobuf.FieldMask} request.updateMask - * The list of fields that you can update. You can update only the description - * and retention period of the final backup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backups_service.update_backup.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_UpdateBackup_async - */ + /** + * Updates the retention period and the description of the backup. You can use + * this API to update final backups only. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.sql.v1beta4.Backup} request.backup + * Required. The backup to update. + * The backup’s `name` field is used to identify the backup to update. + * Format: projects/{project}/backups/{backup} + * @param {google.protobuf.FieldMask} request.updateMask + * The list of fields that you can update. You can update only the description + * and retention period of the final backup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backups_service.update_backup.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_UpdateBackup_async + */ updateBackup( - request?: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | undefined, + {} | undefined, + ] + >; updateBackup( - request: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; updateBackup( - request?: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.IUpdateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.IUpdateBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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}); this._log.info('updateBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.IUpdateBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IUpdateBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IUpdateBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 the backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the backup to delete. - * Format: projects/{project}/backups/{backup} - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_backups_service.delete_backup.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_DeleteBackup_async - */ + /** + * Deletes the backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the backup to delete. + * Format: projects/{project}/backups/{backup} + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_backups_service.delete_backup.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_DeleteBackup_async + */ deleteBackup( - request?: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | undefined, + {} | undefined, + ] + >; deleteBackup( - request: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteBackup( - request?: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.IDeleteBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.IDeleteBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.IDeleteBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.IDeleteBackupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all backups associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.sql.v1beta4.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 associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.sql.v1beta4.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.sql.v1beta4.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackup[], - protos.google.cloud.sql.v1beta4.IListBackupsRequest|null, - protos.google.cloud.sql.v1beta4.IListBackupsResponse - ]>; + request?: protos.google.cloud.sql.v1beta4.IListBackupsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackup[], + protos.google.cloud.sql.v1beta4.IListBackupsRequest | null, + protos.google.cloud.sql.v1beta4.IListBackupsResponse, + ] + >; listBackups( - request: protos.google.cloud.sql.v1beta4.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.sql.v1beta4.IListBackupsRequest, - protos.google.cloud.sql.v1beta4.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1beta4.IBackup>): void; + request: protos.google.cloud.sql.v1beta4.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.sql.v1beta4.IListBackupsRequest, + protos.google.cloud.sql.v1beta4.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1beta4.IBackup + >, + ): void; listBackups( - request: protos.google.cloud.sql.v1beta4.IListBackupsRequest, - callback: PaginationCallback< - protos.google.cloud.sql.v1beta4.IListBackupsRequest, - protos.google.cloud.sql.v1beta4.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1beta4.IBackup>): void; + request: protos.google.cloud.sql.v1beta4.IListBackupsRequest, + callback: PaginationCallback< + protos.google.cloud.sql.v1beta4.IListBackupsRequest, + protos.google.cloud.sql.v1beta4.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1beta4.IBackup + >, + ): void; listBackups( - request?: protos.google.cloud.sql.v1beta4.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.sql.v1beta4.IListBackupsRequest, - protos.google.cloud.sql.v1beta4.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1beta4.IBackup>, - callback?: PaginationCallback< + request?: protos.google.cloud.sql.v1beta4.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.sql.v1beta4.IListBackupsRequest, - protos.google.cloud.sql.v1beta4.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1beta4.IBackup>): - Promise<[ - protos.google.cloud.sql.v1beta4.IBackup[], - protos.google.cloud.sql.v1beta4.IListBackupsRequest|null, - protos.google.cloud.sql.v1beta4.IListBackupsResponse - ]>|void { + | protos.google.cloud.sql.v1beta4.IListBackupsResponse + | null + | undefined, + protos.google.cloud.sql.v1beta4.IBackup + >, + callback?: PaginationCallback< + protos.google.cloud.sql.v1beta4.IListBackupsRequest, + protos.google.cloud.sql.v1beta4.IListBackupsResponse | null | undefined, + protos.google.cloud.sql.v1beta4.IBackup + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IBackup[], + protos.google.cloud.sql.v1beta4.IListBackupsRequest | null, + protos.google.cloud.sql.v1beta4.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.sql.v1beta4.IListBackupsRequest, - protos.google.cloud.sql.v1beta4.IListBackupsResponse|null|undefined, - protos.google.cloud.sql.v1beta4.IBackup>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.sql.v1beta4.IListBackupsRequest, + | protos.google.cloud.sql.v1beta4.IListBackupsResponse + | null + | undefined, + protos.google.cloud.sql.v1beta4.IBackup + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBackups values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -837,137 +1042,142 @@ export class SqlBackupsServiceClient { this._log.info('listBackups request %j', request); return this.innerApiCalls .listBackups(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.sql.v1beta4.IBackup[], - protos.google.cloud.sql.v1beta4.IListBackupsRequest|null, - protos.google.cloud.sql.v1beta4.IListBackupsResponse - ]) => { - this._log.info('listBackups values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.sql.v1beta4.IBackup[], + protos.google.cloud.sql.v1beta4.IListBackupsRequest | null, + protos.google.cloud.sql.v1beta4.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 parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @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.sql.v1beta4.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 parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @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.sql.v1beta4.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.sql.v1beta4.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.sql.v1beta4.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 parent that owns this collection of backups. - * Format: projects/{project} - * @param {number} request.pageSize - * The maximum number of backups to return per response. The service might - * return fewer backups than this value. If a value for this parameter isn't - * specified, then, at most, 500 backups are returned. The maximum value is - * 2,000. Any values that you set, which are greater than 2,000, are changed - * to 2,000. - * @param {string} request.pageToken - * A page token, received from a previous `ListBackups` call. - * Provide this to retrieve the subsequent page. - * - * When paginating, all other parameters provided to `ListBackups` must match - * the call that provided the page token. - * @param {string} request.filter - * Multiple filter queries are separated by spaces. For example, - * 'instance:abc AND type:FINAL, 'location:us', - * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by - * type, instance, backupInterval.startTime (creation time), or location. - * @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.sql.v1beta4.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/v1beta4/sql_backups_service.list_backups.js - * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_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 parent that owns this collection of backups. + * Format: projects/{project} + * @param {number} request.pageSize + * The maximum number of backups to return per response. The service might + * return fewer backups than this value. If a value for this parameter isn't + * specified, then, at most, 500 backups are returned. The maximum value is + * 2,000. Any values that you set, which are greater than 2,000, are changed + * to 2,000. + * @param {string} request.pageToken + * A page token, received from a previous `ListBackups` call. + * Provide this to retrieve the subsequent page. + * + * When paginating, all other parameters provided to `ListBackups` must match + * the call that provided the page token. + * @param {string} request.filter + * Multiple filter queries are separated by spaces. For example, + * 'instance:abc AND type:FINAL, 'location:us', + * 'backupInterval.startTime>=1950-01-01T01:01:25.771Z'. You can filter by + * type, instance, backupInterval.startTime (creation time), or location. + * @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.sql.v1beta4.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/v1beta4/sql_backups_service.list_backups.js + * region_tag:sqladmin_v1beta4_generated_SqlBackupsService_ListBackups_async + */ listBackupsAsync( - request?: protos.google.cloud.sql.v1beta4.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.sql.v1beta4.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 @@ -1002,12 +1212,11 @@ export class SqlBackupsServiceClient { | 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. @@ -1040,7 +1249,7 @@ export class SqlBackupsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1056,7 +1265,7 @@ export class SqlBackupsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -1091,7 +1300,7 @@ export class SqlBackupsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1116,13 +1325,15 @@ export class SqlBackupsServiceClient { */ close(): Promise { if (this.sqlBackupsServiceStub && !this._terminated) { - return this.sqlBackupsServiceStub.then(stub => { + return this.sqlBackupsServiceStub.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-sql/src/v1beta4/sql_connect_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_connect_service_client.ts index 9dd0d4425b76..98f4fcbdfa17 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_connect_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_connect_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlConnectServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlConnectServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlConnectServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlConnectServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlConnectServiceClient. @@ -101,21 +108,42 @@ export class SqlConnectServiceClient { * const client = new SqlConnectServiceClient({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 SqlConnectServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlConnectServiceClient { 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 +182,11 @@ export class SqlConnectServiceClient { } 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,14 +208,17 @@ export class SqlConnectServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlConnectService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlConnectService', + 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 @@ -222,36 +249,43 @@ export class SqlConnectServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlConnectService. this.sqlConnectServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlConnectService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlConnectService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlConnectService, - 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 sqlConnectServiceStubMethods = - ['getConnectSettings', 'generateEphemeralCert']; + const sqlConnectServiceStubMethods = [ + 'getConnectSettings', + 'generateEphemeralCert', + ]; for (const methodName of sqlConnectServiceStubMethods) { const callPromise = this.sqlConnectServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +300,14 @@ export class SqlConnectServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +318,14 @@ export class SqlConnectServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +358,7 @@ export class SqlConnectServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +368,9 @@ export class SqlConnectServiceClient { * 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; @@ -334,217 +381,303 @@ export class SqlConnectServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves connect settings about a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.protobuf.Timestamp} [request.readTime] - * Optional. Optional snapshot read timestamp to trade freshness for - * performance. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.ConnectSettings|ConnectSettings}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_connect_service.get_connect_settings.js - * region_tag:sqladmin_v1beta4_generated_SqlConnectService_GetConnectSettings_async - */ + /** + * Retrieves connect settings about a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.protobuf.Timestamp} [request.readTime] + * Optional. Optional snapshot read timestamp to trade freshness for + * performance. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.ConnectSettings|ConnectSettings}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_connect_service.get_connect_settings.js + * region_tag:sqladmin_v1beta4_generated_SqlConnectService_GetConnectSettings_async + */ getConnectSettings( - request?: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IConnectSettings, + protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest | undefined, + {} | undefined, + ] + >; getConnectSettings( - request: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IConnectSettings, + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectSettings( - request: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IConnectSettings, + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getConnectSettings( - request?: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IConnectSettings, + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IConnectSettings, + protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getConnectSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IConnectSettings, + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getConnectSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getConnectSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IConnectSettings, - protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('getConnectSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getConnectSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IConnectSettings, + ( + | protos.google.cloud.sql.v1beta4.IGetConnectSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getConnectSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.publicKey - * PEM encoded public key to include in the signed certificate. - * @param {string} [request.accessToken] - * Optional. Access token to include in the signed certificate. - * @param {google.protobuf.Timestamp} [request.readTime] - * Optional. Optional snapshot read timestamp to trade freshness for - * performance. - * @param {google.protobuf.Duration} [request.validDuration] - * Optional. If set, it will contain the cert valid duration. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse|GenerateEphemeralCertResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_connect_service.generate_ephemeral_cert.js - * region_tag:sqladmin_v1beta4_generated_SqlConnectService_GenerateEphemeralCert_async - */ + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.publicKey + * PEM encoded public key to include in the signed certificate. + * @param {string} [request.accessToken] + * Optional. Access token to include in the signed certificate. + * @param {google.protobuf.Timestamp} [request.readTime] + * Optional. Optional snapshot read timestamp to trade freshness for + * performance. + * @param {google.protobuf.Duration} [request.validDuration] + * Optional. If set, it will contain the cert valid duration. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse|GenerateEphemeralCertResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_connect_service.generate_ephemeral_cert.js + * region_tag:sqladmin_v1beta4_generated_SqlConnectService_GenerateEphemeralCert_async + */ generateEphemeralCert( - request?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest | undefined, + {} | undefined, + ] + >; generateEphemeralCert( - request: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateEphemeralCert( - request: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; generateEphemeralCert( - request?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('generateEphemeralCert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('generateEphemeralCert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.generateEphemeralCert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, - protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest|undefined, - {}|undefined - ]) => { - this._log.info('generateEphemeralCert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .generateEphemeralCert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse, + ( + | protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('generateEphemeralCert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -579,12 +712,11 @@ export class SqlConnectServiceClient { | 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. @@ -617,7 +749,7 @@ export class SqlConnectServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -633,7 +765,7 @@ export class SqlConnectServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -670,13 +802,15 @@ export class SqlConnectServiceClient { */ close(): Promise { if (this.sqlConnectServiceStub && !this._terminated) { - return this.sqlConnectServiceStub.then(stub => { + return this.sqlConnectServiceStub.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-sql/src/v1beta4/sql_databases_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_databases_service_client.ts index 8be5e2d2de26..acc2d5a1d7c3 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_databases_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_databases_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlDatabasesServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlDatabasesServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlDatabasesServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlDatabasesServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlDatabasesServiceClient. @@ -100,21 +107,42 @@ export class SqlDatabasesServiceClient { * const client = new SqlDatabasesServiceClient({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 SqlDatabasesServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlDatabasesServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlDatabasesServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlDatabasesServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlDatabasesService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlDatabasesService', + 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 @@ -224,36 +251,47 @@ export class SqlDatabasesServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlDatabasesService. this.sqlDatabasesServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlDatabasesService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlDatabasesService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlDatabasesService, - 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 sqlDatabasesServiceStubMethods = - ['delete', 'get', 'insert', 'list', 'patch', 'update']; + const sqlDatabasesServiceStubMethods = [ + 'delete', + 'get', + 'insert', + 'list', + 'patch', + 'update', + ]; for (const methodName of sqlDatabasesServiceStubMethods) { const callPromise = this.sqlDatabasesServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +306,14 @@ export class SqlDatabasesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +324,14 @@ export class SqlDatabasesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +364,7 @@ export class SqlDatabasesServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +374,9 @@ export class SqlDatabasesServiceClient { * 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; @@ -336,611 +387,863 @@ export class SqlDatabasesServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes a database from a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be deleted in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_databases_service.delete.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Delete_async - */ + /** + * Deletes a database from a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be deleted in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_databases_service.delete.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlDatabasesDeleteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a database inside a Cloud - * SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.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/v1beta4/sql_databases_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Get_async - */ + /** + * Retrieves a resource containing information about a database inside a Cloud + * SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.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/v1beta4/sql_databases_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabase, + protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabase, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabase, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IDatabase, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabase, + protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IDatabase, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IDatabase, - protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IDatabase, + protos.google.cloud.sql.v1beta4.ISqlDatabasesGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Inserts a resource containing information about a database inside a Cloud - * SQL instance. - * - * **Note:** You can't modify the default character set and collation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_databases_service.insert.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Insert_async - */ + /** + * Inserts a resource containing information about a database inside a Cloud + * SQL instance. + * + * **Note:** You can't modify the default character set and collation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_databases_service.insert.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlDatabasesInsertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 databases in the specified Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.DatabasesListResponse|DatabasesListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_databases_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_List_async - */ + /** + * Lists databases in the specified Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.DatabasesListResponse|DatabasesListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_databases_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IDatabasesListResponse, - protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IDatabasesListResponse, + protos.google.cloud.sql.v1beta4.ISqlDatabasesListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Partially updates a resource containing information about a database inside - * a Cloud SQL instance. This method supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be updated in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_databases_service.patch.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Patch_async - */ + /** + * Partially updates a resource containing information about a database inside + * a Cloud SQL instance. This method supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be updated in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_databases_service.patch.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Patch_async + */ patch( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + >; patch( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; patch( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; patch( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('patch request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('patch response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.patch(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('patch response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .patch(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('patch response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a resource containing information about a database inside a Cloud - * SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.database - * Name of the database to be updated in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.Database} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_databases_service.update.js - * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Update_async - */ + /** + * Updates a resource containing information about a database inside a Cloud + * SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.database + * Name of the database to be updated in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.Database} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_databases_service.update.js + * region_tag:sqladmin_v1beta4_generated_SqlDatabasesService_Update_async + */ update( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'database': request.database ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + database: request.database ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlDatabasesUpdateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -975,12 +1278,11 @@ export class SqlDatabasesServiceClient { | 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. @@ -1013,7 +1315,7 @@ export class SqlDatabasesServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -1029,7 +1331,7 @@ export class SqlDatabasesServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -1064,7 +1366,7 @@ export class SqlDatabasesServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1089,13 +1391,15 @@ export class SqlDatabasesServiceClient { */ close(): Promise { if (this.sqlDatabasesServiceStub && !this._terminated) { - return this.sqlDatabasesServiceStub.then(stub => { + return this.sqlDatabasesServiceStub.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-sql/src/v1beta4/sql_flags_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_flags_service_client.ts index c8b765e7f710..2ada4fa5a4c1 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_flags_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_flags_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlFlagsServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlFlagsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlFlagsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlFlagsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlFlagsServiceClient. @@ -100,21 +107,42 @@ export class SqlFlagsServiceClient { * const client = new SqlFlagsServiceClient({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 SqlFlagsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlFlagsServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlFlagsServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlFlagsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlFlagsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlFlagsService', + 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 @@ -224,36 +251,40 @@ export class SqlFlagsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlFlagsService. this.sqlFlagsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlFlagsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlFlagsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlFlagsService, - 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 sqlFlagsServiceStubMethods = - ['list']; + const sqlFlagsServiceStubMethods = ['list']; for (const methodName of sqlFlagsServiceStubMethods) { const callPromise = this.sqlFlagsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +299,14 @@ export class SqlFlagsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +317,14 @@ export class SqlFlagsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +357,7 @@ export class SqlFlagsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +367,9 @@ export class SqlFlagsServiceClient { * 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; @@ -336,101 +380,136 @@ export class SqlFlagsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Lists all available database flags for Cloud SQL instances. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.databaseVersion - * Database type and version you want to retrieve flags for. By default, this - * method returns flags for all database types and versions. - * @param {google.cloud.sql.v1beta4.SqlFlagScope} [request.flagScope] - * Optional. Specify the scope of flags to be returned by SqlFlagsListService. - * Return list of database flags if unspecified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.FlagsListResponse|FlagsListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_flags_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlFlagsService_List_async - */ + /** + * Lists all available database flags for Cloud SQL instances. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.databaseVersion + * Database type and version you want to retrieve flags for. By default, this + * method returns flags for all database types and versions. + * @param {google.cloud.sql.v1beta4.SqlFlagScope} [request.flagScope] + * Optional. Specify the scope of flags to be returned by SqlFlagsListService. + * Return list of database flags if unspecified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.FlagsListResponse|FlagsListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_flags_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlFlagsService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IFlagsListResponse, - protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IFlagsListResponse, + protos.google.cloud.sql.v1beta4.ISqlFlagsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -465,12 +544,11 @@ export class SqlFlagsServiceClient { | 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. @@ -503,7 +581,7 @@ export class SqlFlagsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -519,7 +597,7 @@ export class SqlFlagsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -554,7 +632,7 @@ export class SqlFlagsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -579,13 +657,15 @@ export class SqlFlagsServiceClient { */ close(): Promise { if (this.sqlFlagsServiceStub && !this._terminated) { - return this.sqlFlagsServiceStub.then(stub => { + return this.sqlFlagsServiceStub.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-sql/src/v1beta4/sql_instances_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_instances_service_client.ts index dbfed12b86a9..a487606fd449 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_instances_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_instances_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlInstancesServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlInstancesServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlInstancesServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlInstancesServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlInstancesServiceClient. @@ -100,21 +107,42 @@ export class SqlInstancesServiceClient { * const client = new SqlInstancesServiceClient({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 SqlInstancesServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlInstancesServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlInstancesServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlInstancesServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlInstancesService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlInstancesService', + 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 @@ -224,36 +251,84 @@ export class SqlInstancesServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlInstancesService. this.sqlInstancesServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlInstancesService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlInstancesService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlInstancesService, - 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 sqlInstancesServiceStubMethods = - ['addServerCa', 'addServerCertificate', 'addEntraIdCertificate', 'clone', 'delete', 'demoteMaster', 'demote', 'export', 'failover', 'reencrypt', 'get', 'import', 'insert', 'list', 'listServerCas', 'listServerCertificates', 'listEntraIdCertificates', 'patch', 'promoteReplica', 'switchover', 'resetSslConfig', 'restart', 'restoreBackup', 'rotateServerCa', 'rotateServerCertificate', 'rotateEntraIdCertificate', 'startReplica', 'stopReplica', 'truncateLog', 'update', 'createEphemeral', 'rescheduleMaintenance', 'verifyExternalSyncSettings', 'startExternalSync', 'performDiskShrink', 'getDiskShrinkConfig', 'resetReplicaSize', 'getLatestRecoveryTime', 'executeSql', 'acquireSsrsLease', 'releaseSsrsLease', 'preCheckMajorVersionUpgrade', 'pointInTimeRestore']; + const sqlInstancesServiceStubMethods = [ + 'addServerCa', + 'addServerCertificate', + 'addEntraIdCertificate', + 'clone', + 'delete', + 'demoteMaster', + 'demote', + 'export', + 'failover', + 'reencrypt', + 'get', + 'import', + 'insert', + 'list', + 'listServerCas', + 'listServerCertificates', + 'listEntraIdCertificates', + 'patch', + 'promoteReplica', + 'switchover', + 'resetSslConfig', + 'restart', + 'restoreBackup', + 'rotateServerCa', + 'rotateServerCertificate', + 'rotateEntraIdCertificate', + 'startReplica', + 'stopReplica', + 'truncateLog', + 'update', + 'createEphemeral', + 'rescheduleMaintenance', + 'verifyExternalSyncSettings', + 'startExternalSync', + 'performDiskShrink', + 'getDiskShrinkConfig', + 'resetReplicaSize', + 'getLatestRecoveryTime', + 'executeSql', + 'acquireSsrsLease', + 'releaseSsrsLease', + 'preCheckMajorVersionUpgrade', + 'pointInTimeRestore', + ]; for (const methodName of sqlInstancesServiceStubMethods) { const callPromise = this.sqlInstancesServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +343,14 @@ export class SqlInstancesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +361,14 @@ export class SqlInstancesServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +401,7 @@ export class SqlInstancesServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +411,9 @@ export class SqlInstancesServiceClient { * 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; @@ -336,4349 +424,6366 @@ export class SqlInstancesServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Add a new trusted Certificate Authority (CA) version for the specified - * instance. Required to prepare for a certificate rotation. If a CA version - * was previously added but never used in a certificate rotation, this - * operation replaces that version. There cannot be more than one CA version - * waiting to be rotated in. For instances that have enabled Certificate - * Authority Service (CAS) based server CA, use AddServerCertificate to add a - * new server certificate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.add_server_ca.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddServerCa_async - */ + /** + * Add a new trusted Certificate Authority (CA) version for the specified + * instance. Required to prepare for a certificate rotation. If a CA version + * was previously added but never used in a certificate rotation, this + * operation replaces that version. There cannot be more than one CA version + * waiting to be rotated in. For instances that have enabled Certificate + * Authority Service (CAS) based server CA, use AddServerCertificate to add a + * new server certificate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.add_server_ca.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddServerCa_async + */ addServerCa( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | undefined + ), + {} | undefined, + ] + >; addServerCa( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCa( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCa( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addServerCa request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addServerCa response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addServerCa(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest|undefined, - {}|undefined - ]) => { - this._log.info('addServerCa response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addServerCa(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addServerCa response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a new trusted server certificate version for the specified instance - * using Certificate Authority Service (CAS) server CA. Required to prepare - * for a certificate rotation. If a server certificate version was previously - * added but never used in a certificate rotation, this operation replaces - * that version. There cannot be more than one certificate version waiting to - * be rotated in. For instances not using CAS server CA, use AddServerCa - * instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.add_server_certificate.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddServerCertificate_async - */ + /** + * Add a new trusted server certificate version for the specified instance + * using Certificate Authority Service (CAS) server CA. Required to prepare + * for a certificate rotation. If a server certificate version was previously + * added but never used in a certificate rotation, this operation replaces + * that version. There cannot be more than one certificate version waiting to + * be rotated in. For instances not using CAS server CA, use AddServerCa + * instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.add_server_certificate.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddServerCertificate_async + */ addServerCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ] + >; addServerCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addServerCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addServerCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addServerCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addServerCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('addServerCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addServerCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddServerCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addServerCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Adds a new Entra ID certificate for the specified instance. If an Entra ID - * certificate was previously added but never used in a certificate rotation, - * this operation replaces that version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.add_entra_id_certificate.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddEntraIdCertificate_async - */ + /** + * Adds a new Entra ID certificate for the specified instance. If an Entra ID + * certificate was previously added but never used in a certificate rotation, + * this operation replaces that version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.add_entra_id_certificate.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AddEntraIdCertificate_async + */ addEntraIdCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + >; addEntraIdCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addEntraIdCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; addEntraIdCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('addEntraIdCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('addEntraIdCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.addEntraIdCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('addEntraIdCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .addEntraIdCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAddEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('addEntraIdCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance as a clone of the source instance. Using this - * operation might cause your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * The ID of the Cloud SQL instance to be cloned (source). This does not - * include the project ID. - * @param {string} request.project - * Project ID of the source as well as the clone Cloud SQL instance. - * @param {google.cloud.sql.v1beta4.InstancesCloneRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.clone.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Clone_async - */ + /** + * Creates a Cloud SQL instance as a clone of the source instance. Using this + * operation might cause your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The ID of the Cloud SQL instance to be cloned (source). This does not + * include the project ID. + * @param {string} request.project + * Project ID of the source as well as the clone Cloud SQL instance. + * @param {google.cloud.sql.v1beta4.InstancesCloneRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.clone.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Clone_async + */ clone( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ] + >; clone( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + >, + ): void; clone( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + >, + ): void; clone( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('clone request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('clone response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.clone(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest|undefined, - {}|undefined - ]) => { - this._log.info('clone response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .clone(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesCloneRequest | undefined, + {} | undefined, + ]) => { + this._log.info('clone response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be deleted. - * @param {boolean} request.enableFinalBackup - * Flag to opt-in for final backup. By default, it is turned off. - * @param {number} [request.finalBackupTtlDays] - * Optional. Retention period of the final backup. - * @param {google.protobuf.Timestamp} [request.finalBackupExpiryTime] - * Optional. Final Backup expiration time. - * Timestamp in UTC of when this resource is considered expired. - * @param {string} [request.finalBackupDescription] - * Optional. The description of the final backup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.delete.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Delete_async - */ + /** + * Deletes a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be deleted. + * @param {boolean} request.enableFinalBackup + * Flag to opt-in for final backup. By default, it is turned off. + * @param {number} [request.finalBackupTtlDays] + * Optional. Retention period of the final backup. + * @param {google.protobuf.Timestamp} [request.finalBackupExpiryTime] + * Optional. Final Backup expiration time. + * Timestamp in UTC of when this resource is considered expired. + * @param {string} [request.finalBackupDescription] + * Optional. The description of the final backup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.delete.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesDeleteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Demotes the stand-alone instance to be a Cloud SQL read replica for an - * external database server. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance name. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesDemoteMasterRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.demote_master.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_DemoteMaster_async - */ + /** + * Demotes the stand-alone instance to be a Cloud SQL read replica for an + * external database server. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance name. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesDemoteMasterRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.demote_master.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_DemoteMaster_async + */ demoteMaster( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | undefined + ), + {} | undefined, + ] + >; demoteMaster( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demoteMaster( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demoteMaster( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('demoteMaster request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('demoteMaster response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.demoteMaster(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest|undefined, - {}|undefined - ]) => { - this._log.info('demoteMaster response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .demoteMaster(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteMasterRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('demoteMaster response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Demotes an existing standalone instance to be a Cloud SQL read replica - * for an external database server. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. The name of the Cloud SQL instance. - * @param {string} request.project - * Required. The project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesDemoteRequest} request.body - * The request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.demote.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Demote_async - */ + /** + * Demotes an existing standalone instance to be a Cloud SQL read replica + * for an external database server. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. The name of the Cloud SQL instance. + * @param {string} request.project + * Required. The project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesDemoteRequest} request.body + * The request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.demote.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Demote_async + */ demote( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest | undefined, + {} | undefined, + ] + >; demote( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demote( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; demote( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('demote request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('demote response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.demote(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest|undefined, - {}|undefined - ]) => { - this._log.info('demote response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .demote(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesDemoteRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('demote response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL - * dump or CSV file. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * The Cloud SQL instance ID. This doesn't include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be exported. - * @param {google.cloud.sql.v1beta4.InstancesExportRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.export.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Export_async - */ + /** + * Exports data from a Cloud SQL instance to a Cloud Storage bucket as a SQL + * dump or CSV file. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * The Cloud SQL instance ID. This doesn't include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be exported. + * @param {google.cloud.sql.v1beta4.InstancesExportRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.export.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Export_async + */ export( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest | undefined, + {} | undefined, + ] + >; export( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; export( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; export( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('export request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('export response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.export(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest|undefined, - {}|undefined - ]) => { - this._log.info('export response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .export(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesExportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('export response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Initiates a manual failover of a high availability (HA) primary instance - * to a standby instance, which becomes the primary instance. Users are - * then rerouted to the new primary. For more information, see the - * [Overview of high - * availability](https://cloud.google.com/sql/docs/mysql/high-availability) - * page in the Cloud SQL documentation. - * If using Legacy HA (MySQL only), this causes the instance to failover to - * its failover replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {google.cloud.sql.v1beta4.InstancesFailoverRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.failover.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Failover_async - */ + /** + * Initiates a manual failover of a high availability (HA) primary instance + * to a standby instance, which becomes the primary instance. Users are + * then rerouted to the new primary. For more information, see the + * [Overview of high + * availability](https://cloud.google.com/sql/docs/mysql/high-availability) + * page in the Cloud SQL documentation. + * If using Legacy HA (MySQL only), this causes the instance to failover to + * its failover replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {google.cloud.sql.v1beta4.InstancesFailoverRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.failover.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Failover_async + */ failover( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest | undefined, + {} | undefined, + ] + >; failover( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; failover( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; failover( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('failover request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('failover response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.failover(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest|undefined, - {}|undefined - ]) => { - this._log.info('failover response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .failover(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesFailoverRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('failover response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reencrypt CMEK instance with latest key version. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesReencryptRequest} request.body - * Reencrypt body that users 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 an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.reencrypt.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Reencrypt_async - */ + /** + * Reencrypt CMEK instance with latest key version. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesReencryptRequest} request.body + * Reencrypt body that users 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 an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.reencrypt.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Reencrypt_async + */ reencrypt( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest | undefined, + {} | undefined, + ] + >; reencrypt( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reencrypt( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): void; reencrypt( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('reencrypt request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('reencrypt response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.reencrypt(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest|undefined, - {}|undefined - ]) => { - this._log.info('reencrypt response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .reencrypt(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesReencryptRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('reencrypt response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.DatabaseInstance|DatabaseInstance}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Get_async - */ + /** + * Retrieves a resource containing information about a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.DatabaseInstance|DatabaseInstance}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IDatabaseInstance, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IDatabaseInstance, + protos.google.cloud.sql.v1beta4.ISqlInstancesGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Imports data into a Cloud SQL instance from a SQL dump or CSV file in - * Cloud Storage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesImportRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.import.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Import_async - */ + /** + * Imports data into a Cloud SQL instance from a SQL dump or CSV file in + * Cloud Storage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesImportRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.import.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Import_async + */ import( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest | undefined, + {} | undefined, + ] + >; import( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; import( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + >, + ): void; import( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('import request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('import response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.import(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest|undefined, - {}|undefined - ]) => { - this._log.info('import response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .import(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesImportRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('import response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.project - * Project ID of the project to which the newly created Cloud SQL instances - * should belong. - * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.insert.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Insert_async - */ + /** + * Creates a new Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID of the project to which the newly created Cloud SQL instances + * should belong. + * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.insert.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesInsertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 instances under a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.filter - * A filter expression that filters resources listed in the response. - * The expression is in the form of field:value. For example, - * 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per - * their JSON representation, such as 'settings.userLabels.auto_start:true'. - * - * Multiple filter queries are space-separated. For example. - * 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each - * expression is an AND expression. However, you can include AND and OR - * expressions explicitly. - * @param {number} request.maxResults - * The maximum number of instances to return. The service may return fewer - * than this value. - * If unspecified, at most 500 instances are returned. - * The maximum value is 1000; values above 1000 are coerced to 1000. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project for which to list Cloud SQL instances. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.InstancesListResponse|InstancesListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_List_async - */ + /** + * Lists instances under a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.filter + * A filter expression that filters resources listed in the response. + * The expression is in the form of field:value. For example, + * 'instanceType:CLOUD_SQL_INSTANCE'. Fields can be nested as needed as per + * their JSON representation, such as 'settings.userLabels.auto_start:true'. + * + * Multiple filter queries are space-separated. For example. + * 'state:RUNNABLE instanceType:CLOUD_SQL_INSTANCE'. By default, each + * expression is an AND expression. However, you can include AND and OR + * expressions explicitly. + * @param {number} request.maxResults + * The maximum number of instances to return. The service may return fewer + * than this value. + * If unspecified, at most 500 instances are returned. + * The maximum value is 1000; values above 1000 are coerced to 1000. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project for which to list Cloud SQL instances. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.InstancesListResponse|InstancesListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IInstancesListResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IInstancesListResponse, + protos.google.cloud.sql.v1beta4.ISqlInstancesListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all of the trusted Certificate Authorities (CAs) for the specified - * instance. There can be up to three CAs listed: the CA that was used to sign - * the certificate that is currently in use, a CA that has been added but not - * yet used to sign a certificate, and a CA used to sign a certificate that - * has previously rotated out. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.InstancesListServerCasResponse|InstancesListServerCasResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.list_server_cas.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListServerCas_async - */ + /** + * Lists all of the trusted Certificate Authorities (CAs) for the specified + * instance. There can be up to three CAs listed: the CA that was used to sign + * the certificate that is currently in use, a CA that has been added but not + * yet used to sign a certificate, and a CA used to sign a certificate that + * has previously rotated out. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.InstancesListServerCasResponse|InstancesListServerCasResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.list_server_cas.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListServerCas_async + */ listServerCas( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | undefined + ), + {} | undefined, + ] + >; listServerCas( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCas( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCas( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listServerCas request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listServerCas response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listServerCas(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest|undefined, - {}|undefined - ]) => { - this._log.info('listServerCas response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listServerCas(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCasRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listServerCas response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all versions of server certificates and certificate authorities (CAs) - * for the specified instance. There can be up to three sets of certs listed: - * the certificate that is currently in use, a future that has been added but - * not yet used to sign a certificate, and a certificate that has been rotated - * out. For instances not using Certificate Authority Service (CAS) server CA, - * use ListServerCas instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1beta4.InstancesListServerCertificatesResponse|InstancesListServerCertificatesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.list_server_certificates.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListServerCertificates_async - */ + /** + * Lists all versions of server certificates and certificate authorities (CAs) + * for the specified instance. There can be up to three sets of certs listed: + * the certificate that is currently in use, a future that has been added but + * not yet used to sign a certificate, and a certificate that has been rotated + * out. For instances not using Certificate Authority Service (CAS) server CA, + * use ListServerCas instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1beta4.InstancesListServerCertificatesResponse|InstancesListServerCertificatesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.list_server_certificates.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListServerCertificates_async + */ listServerCertificates( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ] + >; listServerCertificates( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCertificates( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listServerCertificates( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listServerCertificates request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listServerCertificates response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listServerCertificates(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest|undefined, - {}|undefined - ]) => { - this._log.info('listServerCertificates response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listServerCertificates(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListServerCertificatesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listServerCertificates response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all versions of EntraID certificates for the specified instance. - * There can be up to three sets of certificates listed: the certificate that - * is currently in use, a future that has been added but not yet used to sign - * a certificate, and a certificate that has been rotated out. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains 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.sql.v1beta4.InstancesListEntraIdCertificatesResponse|InstancesListEntraIdCertificatesResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.list_entra_id_certificates.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListEntraIdCertificates_async - */ + /** + * Lists all versions of EntraID certificates for the specified instance. + * There can be up to three sets of certificates listed: the certificate that + * is currently in use, a future that has been added but not yet used to sign + * a certificate, and a certificate that has been rotated out. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains 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.sql.v1beta4.InstancesListEntraIdCertificatesResponse|InstancesListEntraIdCertificatesResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.list_entra_id_certificates.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ListEntraIdCertificates_async + */ listEntraIdCertificates( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ] + >; listEntraIdCertificates( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listEntraIdCertificates( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): void; listEntraIdCertificates( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('listEntraIdCertificates request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('listEntraIdCertificates response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.listEntraIdCertificates(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest|undefined, - {}|undefined - ]) => { - this._log.info('listEntraIdCertificates response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .listEntraIdCertificates(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesListEntraIdCertificatesRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('listEntraIdCertificates response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Partially updates settings of a Cloud SQL instance by merging the request - * with the current configuration. This method supports patch semantics. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.patch.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Patch_async - */ + /** + * Partially updates settings of a Cloud SQL instance by merging the request + * with the current configuration. This method supports patch semantics. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.patch.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Patch_async + */ patch( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ] + >; patch( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): void; patch( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): void; patch( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('patch request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('patch response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.patch(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest|undefined, - {}|undefined - ]) => { - this._log.info('patch response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .patch(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesPatchRequest | undefined, + {} | undefined, + ]) => { + this._log.info('patch response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Promotes the read replica instance to be an independent Cloud SQL - * primary instance. - * Using this operation might cause your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {boolean} request.failover - * Set to true to invoke a replica failover to the DR replica. - * As part of replica failover, the promote operation attempts - * to add the original primary instance as a replica of the promoted - * DR replica when the original primary instance comes back online. - * If set to false or not specified, then the original primary - * instance becomes an independent Cloud SQL primary 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.promote_replica.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PromoteReplica_async - */ + /** + * Promotes the read replica instance to be an independent Cloud SQL + * primary instance. + * Using this operation might cause your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {boolean} request.failover + * Set to true to invoke a replica failover to the DR replica. + * As part of replica failover, the promote operation attempts + * to add the original primary instance as a replica of the promoted + * DR replica when the original primary instance comes back online. + * If set to false or not specified, then the original primary + * instance becomes an independent Cloud SQL primary 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.promote_replica.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PromoteReplica_async + */ promoteReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | undefined + ), + {} | undefined, + ] + >; promoteReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; promoteReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; promoteReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('promoteReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('promoteReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.promoteReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('promoteReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .promoteReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPromoteReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('promoteReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Switches over from the primary instance to the DR replica - * instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the replica. - * @param {google.protobuf.Duration} [request.dbTimeout] - * Optional. (MySQL and PostgreSQL only) Cloud SQL instance operations - * timeout, which is a sum of all database operations. Default value is 10 - * minutes and can be modified to a maximum value of 24 hours. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.switchover.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Switchover_async - */ + /** + * Switches over from the primary instance to the DR replica + * instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the replica. + * @param {google.protobuf.Duration} [request.dbTimeout] + * Optional. (MySQL and PostgreSQL only) Cloud SQL instance operations + * timeout, which is a sum of all database operations. Default value is 10 + * minutes and can be modified to a maximum value of 24 hours. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.switchover.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Switchover_async + */ switchover( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | undefined + ), + {} | undefined, + ] + >; switchover( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; switchover( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): void; switchover( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('switchover request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('switchover response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.switchover(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest|undefined, - {}|undefined - ]) => { - this._log.info('switchover response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .switchover(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesSwitchoverRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('switchover response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all client certificates and generates a new server SSL certificate - * for the instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest.ResetSslMode} [request.mode] - * Optional. Reset SSL mode to use. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.reset_ssl_config.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ResetSslConfig_async - */ + /** + * Deletes all client certificates and generates a new server SSL certificate + * for the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest.ResetSslMode} [request.mode] + * Optional. Reset SSL mode to use. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.reset_ssl_config.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ResetSslConfig_async + */ resetSslConfig( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | undefined + ), + {} | undefined, + ] + >; resetSslConfig( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetSslConfig( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetSslConfig( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('resetSslConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resetSslConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resetSslConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('resetSslConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resetSslConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetSslConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resetSslConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Restarts a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance to be restarted. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.restart.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Restart_async - */ + /** + * Restarts a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance to be restarted. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.restart.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Restart_async + */ restart( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest | undefined, + {} | undefined, + ] + >; restart( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restart( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restart( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('restart request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('restart response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.restart(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest|undefined, - {}|undefined - ]) => { - this._log.info('restart response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .restart(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestartRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('restart response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Restores a backup of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesRestoreBackupRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.restore_backup.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RestoreBackup_async - */ + /** + * Restores a backup of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesRestoreBackupRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.restore_backup.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RestoreBackup_async + */ restoreBackup( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | undefined + ), + {} | undefined, + ] + >; restoreBackup( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreBackup( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): void; restoreBackup( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('restoreBackup request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('restoreBackup response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.restoreBackup(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest|undefined, - {}|undefined - ]) => { - this._log.info('restoreBackup response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .restoreBackup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRestoreBackupRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('restoreBackup response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the server certificate to one signed by the Certificate Authority - * (CA) version previously added with the addServerCA method. For instances - * that have enabled Certificate Authority Service (CAS) based server CA, - * use RotateServerCertificate to rotate the server certificate. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesRotateServerCaRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.rotate_server_ca.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateServerCa_async - */ + /** + * Rotates the server certificate to one signed by the Certificate Authority + * (CA) version previously added with the addServerCA method. For instances + * that have enabled Certificate Authority Service (CAS) based server CA, + * use RotateServerCertificate to rotate the server certificate. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesRotateServerCaRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.rotate_server_ca.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateServerCa_async + */ rotateServerCa( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | undefined + ), + {} | undefined, + ] + >; rotateServerCa( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCa( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCa( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateServerCa request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateServerCa response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateServerCa(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateServerCa response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateServerCa(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateServerCa response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the server certificate version to one previously added with the - * addServerCertificate method. For instances not using Certificate Authority - * Service (CAS) server CA, use RotateServerCa instead. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesRotateServerCertificateRequest} request.body - * Required. Rotate server certificate request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.rotate_server_certificate.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateServerCertificate_async - */ + /** + * Rotates the server certificate version to one previously added with the + * addServerCertificate method. For instances not using Certificate Authority + * Service (CAS) server CA, use RotateServerCa instead. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesRotateServerCertificateRequest} request.body + * Required. Rotate server certificate request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.rotate_server_certificate.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateServerCertificate_async + */ rotateServerCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ] + >; rotateServerCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateServerCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateServerCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateServerCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateServerCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateServerCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateServerCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateServerCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateServerCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Rotates the Entra Id certificate version to one previously added with the - * addEntraIdCertificate method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesRotateEntraIdCertificateRequest} request.body - * Required. Rotate Entra ID certificate request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.rotate_entra_id_certificate.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateEntraIdCertificate_async - */ + /** + * Rotates the Entra Id certificate version to one previously added with the + * addEntraIdCertificate method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesRotateEntraIdCertificateRequest} request.body + * Required. Rotate Entra ID certificate request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.rotate_entra_id_certificate.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RotateEntraIdCertificate_async + */ rotateEntraIdCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + >; rotateEntraIdCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateEntraIdCertificate( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rotateEntraIdCertificate( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rotateEntraIdCertificate request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rotateEntraIdCertificate response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rotateEntraIdCertificate(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest|undefined, - {}|undefined - ]) => { - this._log.info('rotateEntraIdCertificate response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rotateEntraIdCertificate(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRotateEntraIdCertificateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rotateEntraIdCertificate response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Starts the replication in the read replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.start_replica.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StartReplica_async - */ + /** + * Starts the replication in the read replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.start_replica.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StartReplica_async + */ startReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | undefined + ), + {} | undefined, + ] + >; startReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('startReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('startReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.startReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('startReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .startReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Stops the replication in the read replica instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.stop_replica.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StopReplica_async - */ + /** + * Stops the replication in the read replica instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.stop_replica.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StopReplica_async + */ stopReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | undefined + ), + {} | undefined, + ] + >; stopReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; stopReplica( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): void; stopReplica( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('stopReplica request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('stopReplica response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.stopReplica(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest|undefined, - {}|undefined - ]) => { - this._log.info('stopReplica response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .stopReplica(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStopReplicaRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('stopReplica response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Truncate MySQL general and slow query log tables - * MySQL only. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the Cloud SQL project. - * @param {google.cloud.sql.v1beta4.InstancesTruncateLogRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.truncate_log.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_TruncateLog_async - */ + /** + * Truncate MySQL general and slow query log tables + * MySQL only. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the Cloud SQL project. + * @param {google.cloud.sql.v1beta4.InstancesTruncateLogRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.truncate_log.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_TruncateLog_async + */ truncateLog( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | undefined + ), + {} | undefined, + ] + >; truncateLog( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): void; truncateLog( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): void; truncateLog( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('truncateLog request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('truncateLog response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.truncateLog(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest|undefined, - {}|undefined - ]) => { - this._log.info('truncateLog response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .truncateLog(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesTruncateLogRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('truncateLog response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 settings of a Cloud SQL instance. Using this operation might cause - * your instance to restart. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.update.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Update_async - */ + /** + * Updates settings of a Cloud SQL instance. Using this operation might cause + * your instance to restart. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.DatabaseInstance} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.update.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_Update_async + */ update( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesUpdateRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 short-lived X509 certificate containing the provided public key - * and signed by a private key specific to the target instance. Users may use - * the certificate to authenticate as themselves when connecting to the - * database. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the Cloud SQL project. - * @param {google.cloud.sql.v1beta4.SslCertsCreateEphemeralRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCert|SslCert}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.create_ephemeral.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_CreateEphemeral_async - */ + /** + * Generates a short-lived X509 certificate containing the provided public key + * and signed by a private key specific to the target instance. Users may use + * the certificate to authenticate as themselves when connecting to the + * database. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the Cloud SQL project. + * @param {google.cloud.sql.v1beta4.SslCertsCreateEphemeralRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCert|SslCert}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.create_ephemeral.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_CreateEphemeral_async + */ createEphemeral( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCert, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ] + >; createEphemeral( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEphemeral( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createEphemeral( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCert, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('createEphemeral request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createEphemeral response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createEphemeral(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest|undefined, - {}|undefined - ]) => { - this._log.info('createEphemeral response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createEphemeral(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISslCert, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesCreateEphemeralCertRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createEphemeral response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reschedules the maintenance on the given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequestBody} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.reschedule_maintenance.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RescheduleMaintenance_async - */ + /** + * Reschedules the maintenance on the given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequestBody} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.reschedule_maintenance.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_RescheduleMaintenance_async + */ rescheduleMaintenance( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ] + >; rescheduleMaintenance( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): void; rescheduleMaintenance( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('rescheduleMaintenance request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('rescheduleMaintenance response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.rescheduleMaintenance(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest|undefined, - {}|undefined - ]) => { - this._log.info('rescheduleMaintenance response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .rescheduleMaintenance(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesRescheduleMaintenanceRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('rescheduleMaintenance response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Verify External primary instance external sync settings. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {boolean} request.verifyConnectionOnly - * Flag to enable verifying connection only - * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode - * External sync mode - * @param {boolean} [request.verifyReplicationOnly] - * Optional. Flag to verify settings required by replication setup only - * @param {google.cloud.sql.v1beta4.MySqlSyncConfig} [request.mysqlSyncConfig] - * Optional. MySQL-specific settings for start external sync. - * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] - * Optional. MigrationType configures the migration to use physical files or - * logical dump files. If not set, then the logical dump file configuration is - * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. - * @param {google.cloud.sql.v1beta4.ExternalSyncParallelLevel} [request.syncParallelLevel] - * Optional. Parallel level for initial data sync. Only applicable for - * PostgreSQL. - * @param {number[]} [request.selectedObjects] - * Optional. Migrate only the specified objects from the source instance. If - * this field is empty, then migrate all objects. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse|SqlInstancesVerifyExternalSyncSettingsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.verify_external_sync_settings.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_VerifyExternalSyncSettings_async - */ + /** + * Verify External primary instance external sync settings. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {boolean} request.verifyConnectionOnly + * Flag to enable verifying connection only + * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode + * External sync mode + * @param {boolean} [request.verifyReplicationOnly] + * Optional. Flag to verify settings required by replication setup only + * @param {google.cloud.sql.v1beta4.MySqlSyncConfig} [request.mysqlSyncConfig] + * Optional. MySQL-specific settings for start external sync. + * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] + * Optional. MigrationType configures the migration to use physical files or + * logical dump files. If not set, then the logical dump file configuration is + * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. + * @param {google.cloud.sql.v1beta4.ExternalSyncParallelLevel} [request.syncParallelLevel] + * Optional. Parallel level for initial data sync. Only applicable for + * PostgreSQL. + * @param {number[]} [request.selectedObjects] + * Optional. Migrate only the specified objects from the source instance. If + * this field is empty, then migrate all objects. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse|SqlInstancesVerifyExternalSyncSettingsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.verify_external_sync_settings.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_VerifyExternalSyncSettings_async + */ verifyExternalSyncSettings( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ] + >; verifyExternalSyncSettings( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; verifyExternalSyncSettings( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; verifyExternalSyncSettings( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('verifyExternalSyncSettings request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('verifyExternalSyncSettings response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.verifyExternalSyncSettings(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest|undefined, - {}|undefined - ]) => { - this._log.info('verifyExternalSyncSettings response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .verifyExternalSyncSettings(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('verifyExternalSyncSettings response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Start External primary instance migration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode - * External sync mode. - * @param {boolean} request.skipVerification - * Whether to skip the verification step (VESS). - * @param {google.cloud.sql.v1beta4.MySqlSyncConfig} request.mysqlSyncConfig - * MySQL-specific settings for start external sync. - * @param {google.cloud.sql.v1beta4.ExternalSyncParallelLevel} [request.syncParallelLevel] - * Optional. Parallel level for initial data sync. Currently only applicable - * for MySQL. - * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] - * Optional. MigrationType configures the migration to use physical files or - * logical dump files. If not set, then the logical dump file configuration is - * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. - * @param {boolean} [request.replicaOverwriteEnabled] - * Optional. MySQL only. True if end-user has confirmed that this SES call - * will wipe replica databases overlapping with the proposed selected_objects. - * If this field is not set and there are both overlapping and additional - * databases proposed, an error 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 an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.start_external_sync.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StartExternalSync_async - */ + /** + * Start External primary instance migration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.ExternalSyncMode} request.syncMode + * External sync mode. + * @param {boolean} request.skipVerification + * Whether to skip the verification step (VESS). + * @param {google.cloud.sql.v1beta4.MySqlSyncConfig} request.mysqlSyncConfig + * MySQL-specific settings for start external sync. + * @param {google.cloud.sql.v1beta4.ExternalSyncParallelLevel} [request.syncParallelLevel] + * Optional. Parallel level for initial data sync. Currently only applicable + * for MySQL. + * @param {google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest.MigrationType} [request.migrationType] + * Optional. MigrationType configures the migration to use physical files or + * logical dump files. If not set, then the logical dump file configuration is + * used. Valid values are `LOGICAL` or `PHYSICAL`. Only applicable to MySQL. + * @param {boolean} [request.replicaOverwriteEnabled] + * Optional. MySQL only. True if end-user has confirmed that this SES call + * will wipe replica databases overlapping with the proposed selected_objects. + * If this field is not set and there are both overlapping and additional + * databases proposed, an error 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 an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.start_external_sync.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_StartExternalSync_async + */ startExternalSync( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ] + >; startExternalSync( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startExternalSync( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): void; startExternalSync( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('startExternalSync request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('startExternalSync response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.startExternalSync(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest|undefined, - {}|undefined - ]) => { - this._log.info('startExternalSync response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .startExternalSync(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesStartExternalSyncRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('startExternalSync response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Perform Disk Shrink on primary instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.PerformDiskShrinkContext} request.body - * Perform disk shrink context. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.perform_disk_shrink.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PerformDiskShrink_async - */ + /** + * Perform Disk Shrink on primary instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.PerformDiskShrinkContext} request.body + * Perform disk shrink context. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.perform_disk_shrink.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PerformDiskShrink_async + */ performDiskShrink( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ] + >; performDiskShrink( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; performDiskShrink( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): void; performDiskShrink( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('performDiskShrink request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('performDiskShrink response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.performDiskShrink(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest|undefined, - {}|undefined - ]) => { - this._log.info('performDiskShrink response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .performDiskShrink(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPerformDiskShrinkRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('performDiskShrink response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Disk Shrink Config for a given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse|SqlInstancesGetDiskShrinkConfigResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.get_disk_shrink_config.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_GetDiskShrinkConfig_async - */ + /** + * Get Disk Shrink Config for a given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse|SqlInstancesGetDiskShrinkConfigResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.get_disk_shrink_config.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_GetDiskShrinkConfig_async + */ getDiskShrinkConfig( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ] + >; getDiskShrinkConfig( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDiskShrinkConfig( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDiskShrinkConfig( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getDiskShrinkConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDiskShrinkConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDiskShrinkConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDiskShrinkConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getDiskShrinkConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDiskShrinkConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Reset Replica Size to primary instance disk size. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL read replica instance name. - * @param {string} request.project - * ID of the project that contains the read replica. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.reset_replica_size.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ResetReplicaSize_async - */ + /** + * Reset Replica Size to primary instance disk size. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL read replica instance name. + * @param {string} request.project + * ID of the project that contains the read replica. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.reset_replica_size.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ResetReplicaSize_async + */ resetReplicaSize( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ] + >; resetReplicaSize( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetReplicaSize( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; resetReplicaSize( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('resetReplicaSize request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resetReplicaSize response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.resetReplicaSize(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest|undefined, - {}|undefined - ]) => { - this._log.info('resetReplicaSize response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resetReplicaSize(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesResetReplicaSizeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('resetReplicaSize response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 Latest Recovery Time for a given instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.protobuf.Timestamp} request.sourceInstanceDeletionTime - * The timestamp used to identify the time when the source instance is - * deleted. If this instance is deleted, then you must set the timestamp. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse|SqlInstancesGetLatestRecoveryTimeResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.get_latest_recovery_time.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_GetLatestRecoveryTime_async - */ + /** + * Get Latest Recovery Time for a given instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.protobuf.Timestamp} request.sourceInstanceDeletionTime + * The timestamp used to identify the time when the source instance is + * deleted. If this instance is deleted, then you must set the timestamp. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse|SqlInstancesGetLatestRecoveryTimeResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.get_latest_recovery_time.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_GetLatestRecoveryTime_async + */ getLatestRecoveryTime( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ] + >; getLatestRecoveryTime( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLatestRecoveryTime( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getLatestRecoveryTime( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('getLatestRecoveryTime request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getLatestRecoveryTime response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getLatestRecoveryTime(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest|undefined, - {}|undefined - ]) => { - this._log.info('getLatestRecoveryTime response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getLatestRecoveryTime(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getLatestRecoveryTime response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Execute SQL statements. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Database instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.ExecuteSqlPayload} request.body - * The request body. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse|SqlInstancesExecuteSqlResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.execute_sql.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ExecuteSql_async - */ + /** + * Execute SQL statements. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Database instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.ExecuteSqlPayload} request.body + * The request body. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse|SqlInstancesExecuteSqlResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.execute_sql.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ExecuteSql_async + */ executeSql( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | undefined + ), + {} | undefined, + ] + >; executeSql( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeSql( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; executeSql( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('executeSql request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('executeSql response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.executeSql(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest|undefined, - {}|undefined - ]) => { - this._log.info('executeSql response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .executeSql(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('executeSql response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Acquire a lease for the setup of SQL Server Reporting Services (SSRS). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This doesn't include the project ID. It's - * composed of lowercase letters, numbers, and hyphens, and it must start with - * a letter. The total length must be 98 characters or less (Example: - * instance-id). - * @param {string} request.project - * Required. ID of the project that contains the instance (Example: - * project-id). - * @param {google.cloud.sql.v1beta4.InstancesAcquireSsrsLeaseRequest} request.body - * The body for request to acquire an SSRS lease. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse|SqlInstancesAcquireSsrsLeaseResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.acquire_ssrs_lease.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AcquireSsrsLease_async - */ + /** + * Acquire a lease for the setup of SQL Server Reporting Services (SSRS). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This doesn't include the project ID. It's + * composed of lowercase letters, numbers, and hyphens, and it must start with + * a letter. The total length must be 98 characters or less (Example: + * instance-id). + * @param {string} request.project + * Required. ID of the project that contains the instance (Example: + * project-id). + * @param {google.cloud.sql.v1beta4.InstancesAcquireSsrsLeaseRequest} request.body + * The body for request to acquire an SSRS lease. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse|SqlInstancesAcquireSsrsLeaseResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.acquire_ssrs_lease.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_AcquireSsrsLease_async + */ acquireSsrsLease( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + >; acquireSsrsLease( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acquireSsrsLease( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acquireSsrsLease( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('acquireSsrsLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('acquireSsrsLease response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.acquireSsrsLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('acquireSsrsLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .acquireSsrsLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('acquireSsrsLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Release a lease for the setup of SQL Server Reporting Services (SSRS). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. The Cloud SQL instance ID. This doesn't include the project ID. - * It's composed of lowercase letters, numbers, and hyphens, and it must start - * with a letter. The total length must be 98 characters or less (Example: - * instance-id). - * @param {string} request.project - * Required. The ID of the project that contains the instance (Example: - * project-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.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse|SqlInstancesReleaseSsrsLeaseResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.release_ssrs_lease.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ReleaseSsrsLease_async - */ + /** + * Release a lease for the setup of SQL Server Reporting Services (SSRS). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. The Cloud SQL instance ID. This doesn't include the project ID. + * It's composed of lowercase letters, numbers, and hyphens, and it must start + * with a letter. The total length must be 98 characters or less (Example: + * instance-id). + * @param {string} request.project + * Required. The ID of the project that contains the instance (Example: + * project-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.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse|SqlInstancesReleaseSsrsLeaseResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.release_ssrs_lease.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_ReleaseSsrsLease_async + */ releaseSsrsLease( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + >; releaseSsrsLease( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; releaseSsrsLease( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; releaseSsrsLease( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('releaseSsrsLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('releaseSsrsLease response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.releaseSsrsLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, - protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('releaseSsrsLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .releaseSsrsLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('releaseSsrsLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Execute MVU Pre-checks - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Required. Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Required. Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.InstancesPreCheckMajorVersionUpgradeRequest} request.body - * Required. The context for request to perform the pre-check major version - * upgrade operation. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.pre_check_major_version_upgrade.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PreCheckMajorVersionUpgrade_async - */ + /** + * Execute MVU Pre-checks + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Required. Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Required. Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.InstancesPreCheckMajorVersionUpgradeRequest} request.body + * Required. The context for request to perform the pre-check major version + * upgrade operation. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.pre_check_major_version_upgrade.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PreCheckMajorVersionUpgrade_async + */ preCheckMajorVersionUpgrade( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ] + >; preCheckMajorVersionUpgrade( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; preCheckMajorVersionUpgrade( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): void; preCheckMajorVersionUpgrade( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('preCheckMajorVersionUpgrade request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('preCheckMajorVersionUpgrade response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.preCheckMajorVersionUpgrade(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest|undefined, - {}|undefined - ]) => { - this._log.info('preCheckMajorVersionUpgrade response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .preCheckMajorVersionUpgrade(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPreCheckMajorVersionUpgradeRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('preCheckMajorVersionUpgrade response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Point in time restore for an instance managed by Google Cloud Backup and - * Disaster Recovery. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The parent resource where you created this instance. - * Format: projects/{project} - * @param {google.cloud.sql.v1beta4.PointInTimeRestoreContext} request.context - * Required. The context for request to perform a PITR on a Google Cloud - * Backup and Disaster Recovery managed 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_instances_service.point_in_time_restore.js - * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PointInTimeRestore_async - */ + /** + * Point in time restore for an instance managed by Google Cloud Backup and + * Disaster Recovery. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource where you created this instance. + * Format: projects/{project} + * @param {google.cloud.sql.v1beta4.PointInTimeRestoreContext} request.context + * Required. The context for request to perform a PITR on a Google Cloud + * Backup and Disaster Recovery managed 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_instances_service.point_in_time_restore.js + * region_tag:sqladmin_v1beta4_generated_SqlInstancesService_PointInTimeRestore_async + */ pointInTimeRestore( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ] + >; pointInTimeRestore( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): void; pointInTimeRestore( - request: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): void; pointInTimeRestore( - request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('pointInTimeRestore request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('pointInTimeRestore response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.pointInTimeRestore(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest|undefined, - {}|undefined - ]) => { - this._log.info('pointInTimeRestore response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .pointInTimeRestore(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + ( + | protos.google.cloud.sql.v1beta4.ISqlInstancesPointInTimeRestoreRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('pointInTimeRestore response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -4713,12 +6818,11 @@ export class SqlInstancesServiceClient { | 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. @@ -4751,7 +6855,7 @@ export class SqlInstancesServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -4767,7 +6871,7 @@ export class SqlInstancesServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -4802,7 +6906,7 @@ export class SqlInstancesServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -4827,13 +6931,15 @@ export class SqlInstancesServiceClient { */ close(): Promise { if (this.sqlInstancesServiceStub && !this._terminated) { - return this.sqlInstancesServiceStub.then(stub => { + return this.sqlInstancesServiceStub.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-sql/src/v1beta4/sql_operations_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_operations_service_client.ts index 8889aa76f6d8..ceb1fa381192 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_operations_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_operations_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlOperationsServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlOperationsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlOperationsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlOperationsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlOperationsServiceClient. @@ -100,21 +107,42 @@ export class SqlOperationsServiceClient { * const client = new SqlOperationsServiceClient({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 SqlOperationsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlOperationsServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlOperationsServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlOperationsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlOperationsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlOperationsService', + 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 @@ -224,36 +251,40 @@ export class SqlOperationsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlOperationsService. this.sqlOperationsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlOperationsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlOperationsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlOperationsService, - 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 sqlOperationsServiceStubMethods = - ['get', 'list', 'cancel']; + const sqlOperationsServiceStubMethods = ['get', 'list', 'cancel']; for (const methodName of sqlOperationsServiceStubMethods) { const callPromise = this.sqlOperationsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +299,14 @@ export class SqlOperationsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +317,14 @@ export class SqlOperationsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +357,7 @@ export class SqlOperationsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +367,9 @@ export class SqlOperationsServiceClient { * 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; @@ -336,305 +380,428 @@ export class SqlOperationsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieves an instance operation that has been performed on an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.operation - * Instance operation ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_operations_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_Get_async - */ + /** + * Retrieves an instance operation that has been performed on an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Instance operation ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_operations_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'operation': request.operation ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + operation: request.operation ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlOperationsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all instance operations that have been performed on the given Cloud - * SQL instance in the reverse chronological order of the start time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {number} request.maxResults - * Maximum number of operations per response. - * @param {string} request.pageToken - * A previously-returned page token representing part of the larger set of - * results to view. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.OperationsListResponse|OperationsListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_operations_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_List_async - */ + /** + * Lists all instance operations that have been performed on the given Cloud + * SQL instance in the reverse chronological order of the start time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {number} request.maxResults + * Maximum number of operations per response. + * @param {string} request.pageToken + * A previously-returned page token representing part of the larger set of + * results to view. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.OperationsListResponse|OperationsListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_operations_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperationsListResponse, - protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperationsListResponse, + protos.google.cloud.sql.v1beta4.ISqlOperationsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Cancels an instance operation that has been performed on an instance. - * Ordinarily, this method name should be `CancelSqlOperation`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.operation - * Instance operation ID. - * @param {string} request.project - * Project ID of the project that contains 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.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/v1beta4/sql_operations_service.cancel.js - * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_Cancel_async - */ + /** + * Cancels an instance operation that has been performed on an instance. + * Ordinarily, this method name should be `CancelSqlOperation`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.operation + * Instance operation ID. + * @param {string} request.project + * Project ID of the project that contains 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.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/v1beta4/sql_operations_service.cancel.js + * region_tag:sqladmin_v1beta4_generated_SqlOperationsService_Cancel_async + */ cancel( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest | undefined, + {} | undefined, + ] + >; cancel( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + >, + ): void; cancel( - request: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + >, + ): void; cancel( - request?: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'operation': request.operation ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + operation: request.operation ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('cancel request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('cancel response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.cancel(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest|undefined, - {}|undefined - ]) => { - this._log.info('cancel response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .cancel(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.sql.v1beta4.ISqlOperationsCancelRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('cancel response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -669,12 +836,11 @@ export class SqlOperationsServiceClient { | 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. @@ -707,7 +873,7 @@ export class SqlOperationsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -723,7 +889,7 @@ export class SqlOperationsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -758,7 +924,7 @@ export class SqlOperationsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -783,13 +949,15 @@ export class SqlOperationsServiceClient { */ close(): Promise { if (this.sqlOperationsServiceStub && !this._terminated) { - return this.sqlOperationsServiceStub.then(stub => { + return this.sqlOperationsServiceStub.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-sql/src/v1beta4/sql_ssl_certs_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_ssl_certs_service_client.ts index 017e4fb36684..aeb3ba6c3aa3 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_ssl_certs_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_ssl_certs_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlSslCertsServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlSslCertsServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlSslCertsServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlSslCertsServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlSslCertsServiceClient. @@ -100,21 +107,42 @@ export class SqlSslCertsServiceClient { * const client = new SqlSslCertsServiceClient({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 SqlSslCertsServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlSslCertsServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlSslCertsServiceClient { } 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 { @@ -183,17 +207,20 @@ export class SqlSslCertsServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlSslCertsService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlSslCertsService', + 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 @@ -224,36 +251,40 @@ export class SqlSslCertsServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlSslCertsService. this.sqlSslCertsServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlSslCertsService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlSslCertsService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlSslCertsService, - 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 sqlSslCertsServiceStubMethods = - ['delete', 'get', 'insert', 'list']; + const sqlSslCertsServiceStubMethods = ['delete', 'get', 'insert', 'list']; for (const methodName of sqlSslCertsServiceStubMethods) { const callPromise = this.sqlSslCertsServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -268,8 +299,14 @@ export class SqlSslCertsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -280,8 +317,14 @@ export class SqlSslCertsServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -314,7 +357,7 @@ export class SqlSslCertsServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -324,8 +367,9 @@ export class SqlSslCertsServiceClient { * 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; @@ -336,408 +380,562 @@ export class SqlSslCertsServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes the SSL certificate. For First Generation instances, the - * certificate remains valid until the instance is restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.sha1Fingerprint - * Sha1 FingerPrint. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_ssl_certs_service.delete.js - * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Delete_async - */ + /** + * Deletes the SSL certificate. For First Generation instances, the + * certificate remains valid until the instance is restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.sha1Fingerprint + * Sha1 FingerPrint. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_ssl_certs_service.delete.js + * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'sha1_fingerprint': request.sha1Fingerprint ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + sha1_fingerprint: request.sha1Fingerprint ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlSslCertsDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a particular SSL certificate. Does not include the private key - * (required for usage). The private key must be saved from the response to - * initial creation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.sha1Fingerprint - * Sha1 FingerPrint. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCert|SslCert}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_ssl_certs_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Get_async - */ + /** + * Retrieves a particular SSL certificate. Does not include the private key + * (required for usage). The private key must be saved from the response to + * initial creation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.sha1Fingerprint + * Sha1 FingerPrint. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCert|SslCert}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_ssl_certs_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'sha1_fingerprint': request.sha1Fingerprint ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + sha1_fingerprint: request.sha1Fingerprint ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISslCert, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISslCert, - protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISslCert, + protos.google.cloud.sql.v1beta4.ISqlSslCertsGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 SSL certificate and returns it along with the private key and - * server certificate authority. The new certificate will not be usable until - * the instance is restarted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.SslCertsInsertRequest} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCertsInsertResponse|SslCertsInsertResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_ssl_certs_service.insert.js - * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Insert_async - */ + /** + * Creates an SSL certificate and returns it along with the private key and + * server certificate authority. The new certificate will not be usable until + * the instance is restarted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.SslCertsInsertRequest} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.SslCertsInsertResponse|SslCertsInsertResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_ssl_certs_service.insert.js + * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all of the current SSL certificates for the instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Cloud SQL instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.SslCertsListResponse|SslCertsListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_ssl_certs_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_List_async - */ + /** + * Lists all of the current SSL certificates for the instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Cloud SQL instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.SslCertsListResponse|SslCertsListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_ssl_certs_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlSslCertsService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest + | null + | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + | protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ISslCertsListResponse, - protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ISslCertsListResponse, + protos.google.cloud.sql.v1beta4.ISqlSslCertsListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -772,12 +970,11 @@ export class SqlSslCertsServiceClient { | 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. @@ -810,7 +1007,7 @@ export class SqlSslCertsServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -826,7 +1023,7 @@ export class SqlSslCertsServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -861,7 +1058,7 @@ export class SqlSslCertsServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -886,13 +1083,15 @@ export class SqlSslCertsServiceClient { */ close(): Promise { if (this.sqlSslCertsServiceStub && !this._terminated) { - return this.sqlSslCertsServiceStub.then(stub => { + return this.sqlSslCertsServiceStub.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-sql/src/v1beta4/sql_tiers_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_tiers_service_client.ts index 3491ba057e4e..599f74109a04 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_tiers_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_tiers_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 +51,7 @@ export class SqlTiersServiceClient { 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('sql'); @@ -57,10 +64,10 @@ export class SqlTiersServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlTiersServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlTiersServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlTiersServiceClient. @@ -101,21 +108,42 @@ export class SqlTiersServiceClient { * const client = new SqlTiersServiceClient({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 SqlTiersServiceClient; - 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 = 'sqladmin.' + 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 +168,7 @@ export class SqlTiersServiceClient { 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 +182,11 @@ export class SqlTiersServiceClient { } 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,14 +208,17 @@ export class SqlTiersServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlTiersService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlTiersService', + 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 @@ -222,36 +249,40 @@ export class SqlTiersServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlTiersService. this.sqlTiersServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlTiersService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlTiersService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlTiersService, - 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 sqlTiersServiceStubMethods = - ['list']; + const sqlTiersServiceStubMethods = ['list']; for (const methodName of sqlTiersServiceStubMethods) { const callPromise = this.sqlTiersServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +297,14 @@ export class SqlTiersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -278,8 +315,14 @@ export class SqlTiersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -312,7 +355,7 @@ export class SqlTiersServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -322,8 +365,9 @@ export class SqlTiersServiceClient { * 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; @@ -334,103 +378,137 @@ export class SqlTiersServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Lists all available machine types (tiers) for Cloud SQL, for example, - * `db-custom-1-3840`. For related information, see [Pricing](/sql/pricing). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.project - * Project ID of the project for which to list tiers. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.TiersListResponse|TiersListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_tiers_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlTiersService_List_async - */ + /** + * Lists all available machine types (tiers) for Cloud SQL, for example, + * `db-custom-1-3840`. For related information, see [Pricing](/sql/pricing). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.project + * Project ID of the project for which to list tiers. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.TiersListResponse|TiersListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_tiers_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlTiersService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlTiersListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlTiersListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.ITiersListResponse, + | protos.google.cloud.sql.v1beta4.ISqlTiersListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.ITiersListResponse, - protos.google.cloud.sql.v1beta4.ISqlTiersListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.ITiersListResponse, + protos.google.cloud.sql.v1beta4.ISqlTiersListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -465,12 +543,11 @@ export class SqlTiersServiceClient { | 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. @@ -503,7 +580,7 @@ export class SqlTiersServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -519,7 +596,7 @@ export class SqlTiersServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -556,13 +633,15 @@ export class SqlTiersServiceClient { */ close(): Promise { if (this.sqlTiersServiceStub && !this._terminated) { - return this.sqlTiersServiceStub.then(stub => { + return this.sqlTiersServiceStub.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-sql/src/v1beta4/sql_users_service_client.ts b/packages/google-cloud-sql/src/v1beta4/sql_users_service_client.ts index 0f2b60605587..2f95c603fe50 100644 --- a/packages/google-cloud-sql/src/v1beta4/sql_users_service_client.ts +++ b/packages/google-cloud-sql/src/v1beta4/sql_users_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, LocationsClient, LocationProtos} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + LocationsClient, + LocationProtos, +} from 'google-gax'; 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 @@ -43,7 +50,7 @@ export class SqlUsersServiceClient { 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('sql'); @@ -56,10 +63,10 @@ export class SqlUsersServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - sqlUsersServiceStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + sqlUsersServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of SqlUsersServiceClient. @@ -100,21 +107,42 @@ export class SqlUsersServiceClient { * const client = new SqlUsersServiceClient({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 SqlUsersServiceClient; - 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 = 'sqladmin.' + 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; @@ -139,7 +167,7 @@ export class SqlUsersServiceClient { 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; @@ -153,15 +181,11 @@ export class SqlUsersServiceClient { } 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 { @@ -183,14 +207,17 @@ export class SqlUsersServiceClient { // Create useful helper objects for these. this.pathTemplates = { backupPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/backups/{backup}' + 'projects/{project}/backups/{backup}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.sql.v1beta4.SqlUsersService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.sql.v1beta4.SqlUsersService', + 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 @@ -221,36 +248,46 @@ export class SqlUsersServiceClient { // Put together the "service stub" for // google.cloud.sql.v1beta4.SqlUsersService. this.sqlUsersServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.sql.v1beta4.SqlUsersService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.sql.v1beta4.SqlUsersService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.sql.v1beta4.SqlUsersService, - 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 sqlUsersServiceStubMethods = - ['delete', 'get', 'insert', 'list', 'update']; + const sqlUsersServiceStubMethods = [ + 'delete', + 'get', + 'insert', + 'list', + 'update', + ]; for (const methodName of sqlUsersServiceStubMethods) { const callPromise = this.sqlUsersServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -265,8 +302,14 @@ export class SqlUsersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -277,8 +320,14 @@ export class SqlUsersServiceClient { * @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 'sqladmin.googleapis.com'; } @@ -311,7 +360,7 @@ export class SqlUsersServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/sqlservice.admin' + 'https://www.googleapis.com/auth/sqlservice.admin', ]; } @@ -321,8 +370,9 @@ export class SqlUsersServiceClient { * 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; @@ -333,515 +383,685 @@ export class SqlUsersServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Deletes a user from a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.host - * Host of the user in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * Name of the user in the instance. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_users_service.delete.js - * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Delete_async - */ + /** + * Deletes a user from a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.host + * Host of the user in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * Name of the user in the instance. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_users_service.delete.js + * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Delete_async + */ delete( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ] + >; delete( - request: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): void; delete( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('delete request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('delete response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.delete(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest|undefined, - {}|undefined - ]) => { - this._log.info('delete response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .delete(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersDeleteRequest | undefined, + {} | undefined, + ]) => { + this._log.info('delete response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves a resource containing information about a user. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * User of the instance. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string} request.host - * Host of a user of 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.sql.v1beta4.User|User}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_users_service.get.js - * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Get_async - */ + /** + * Retrieves a resource containing information about a user. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * User of the instance. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string} request.host + * Host of a user of 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.sql.v1beta4.User|User}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_users_service.get.js + * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Get_async + */ get( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | undefined, + {} | undefined, + ] + >; get( - request: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): void; get( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', - 'name': request.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + name: request.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('get request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IUser, + | protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('get response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.get(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IUser, - protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest|undefined, - {}|undefined - ]) => { - this._log.info('get response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .get(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IUser, + protos.google.cloud.sql.v1beta4.ISqlUsersGetRequest | undefined, + {} | undefined, + ]) => { + this._log.info('get response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 user in a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {google.cloud.sql.v1beta4.User} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_users_service.insert.js - * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Insert_async - */ + /** + * Creates a new user in a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {google.cloud.sql.v1beta4.User} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_users_service.insert.js + * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Insert_async + */ insert( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | undefined, + {} | undefined, + ] + >; insert( - request: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): void; insert( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('insert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('insert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.insert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest|undefined, - {}|undefined - ]) => { - this._log.info('insert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .insert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersInsertRequest | undefined, + {} | undefined, + ]) => { + this._log.info('insert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 users in the specified Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.project - * Project ID of the project that contains 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.sql.v1beta4.UsersListResponse|UsersListResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_users_service.list.js - * region_tag:sqladmin_v1beta4_generated_SqlUsersService_List_async - */ + /** + * Lists users in the specified Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.project + * Project ID of the project that contains 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.sql.v1beta4.UsersListResponse|UsersListResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_users_service.list.js + * region_tag:sqladmin_v1beta4_generated_SqlUsersService_List_async + */ list( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | undefined, + {} | undefined, + ] + >; list( - request: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): void; list( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlUsersListRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlUsersListRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('list request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IUsersListResponse, + | protos.google.cloud.sql.v1beta4.ISqlUsersListRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('list response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.list(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IUsersListResponse, - protos.google.cloud.sql.v1beta4.ISqlUsersListRequest|undefined, - {}|undefined - ]) => { - this._log.info('list response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .list(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IUsersListResponse, + protos.google.cloud.sql.v1beta4.ISqlUsersListRequest | undefined, + {} | undefined, + ]) => { + this._log.info('list response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 an existing user in a Cloud SQL instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} [request.host] - * Optional. Host of the user in the instance. - * @param {string} request.instance - * Database instance ID. This does not include the project ID. - * @param {string} request.name - * Name of the user in the instance. - * @param {string} request.project - * Project ID of the project that contains the instance. - * @param {string[]} [request.databaseRoles] - * Optional. List of database roles to grant to the user. body.database_roles - * will be ignored for update request. - * @param {boolean} [request.revokeExistingRoles] - * Optional. Specifies whether to revoke existing roles that are not present - * in the `database_roles` field. If `false` or unset, the database roles - * specified in `database_roles` are added to the user's existing roles. - * @param {google.cloud.sql.v1beta4.User} request.body - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v1beta4/sql_users_service.update.js - * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Update_async - */ + /** + * Updates an existing user in a Cloud SQL instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} [request.host] + * Optional. Host of the user in the instance. + * @param {string} request.instance + * Database instance ID. This does not include the project ID. + * @param {string} request.name + * Name of the user in the instance. + * @param {string} request.project + * Project ID of the project that contains the instance. + * @param {string[]} [request.databaseRoles] + * Optional. List of database roles to grant to the user. body.database_roles + * will be ignored for update request. + * @param {boolean} [request.revokeExistingRoles] + * Optional. Specifies whether to revoke existing roles that are not present + * in the `database_roles` field. If `false` or unset, the database roles + * specified in `database_roles` are added to the user's existing roles. + * @param {google.cloud.sql.v1beta4.User} request.body + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.sql.v1beta4.Operation|Operation}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v1beta4/sql_users_service.update.js + * region_tag:sqladmin_v1beta4_generated_SqlUsersService_Update_async + */ update( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ] + >; update( - request: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, - callback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, + callback: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): void; update( - request?: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'project': request.project ?? '', - 'instance': request.instance ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + project: request.project ?? '', + instance: request.instance ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('update request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.sql.v1beta4.IOperation, + | protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('update response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.update(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.sql.v1beta4.IOperation, - protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest|undefined, - {}|undefined - ]) => { - this._log.info('update response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .update(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.sql.v1beta4.IOperation, + protos.google.cloud.sql.v1beta4.ISqlUsersUpdateRequest | undefined, + {} | undefined, + ]) => { + this._log.info('update response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 information about a location. * * @param {Object} request @@ -876,12 +1096,11 @@ export class SqlUsersServiceClient { | 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. @@ -914,7 +1133,7 @@ export class SqlUsersServiceClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -930,7 +1149,7 @@ export class SqlUsersServiceClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,backup:string) { + backupPath(project: string, backup: string) { return this.pathTemplates.backupPathTemplate.render({ project: project, backup: backup, @@ -967,13 +1186,15 @@ export class SqlUsersServiceClient { */ close(): Promise { if (this.sqlUsersServiceStub && !this._terminated) { - return this.sqlUsersServiceStub.then(stub => { + return this.sqlUsersServiceStub.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-sql/system-test/install.ts b/packages/google-cloud-sql/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-sql/system-test/install.ts +++ b/packages/google-cloud-sql/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-sql/test/gapic_sql_backup_runs_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1.ts index ef97c1615c76..39a4cbb474bb 100644 --- a/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1.ts @@ -19,927 +19,1174 @@ 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 sqlbackuprunsserviceModule from '../src'; -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 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.SqlBackupRunsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); - 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 = sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); + 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 = + sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('has port', () => { - const port = sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - fallback: true, + 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + universeDomain: 'configured.example.com', }); - assert(client); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); - await client.initialize(); - assert(client.sqlBackupRunsServiceStub); + it('has port', () => { + const port = + sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlBackupRunsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); + await client.initialize(); + assert(client.sqlBackupRunsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlBackupRunsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); - }); - - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.BackupRun() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.BackupRun() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IBackupRun|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); - }); - - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); - }); - - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.BackupRunsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.BackupRunsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IBackupRunsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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('delete', () => { + it('invokes delete without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.BackupRun(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.BackupRun(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IBackupRun | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.BackupRunsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.BackupRunsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IBackupRunsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlbackuprunsserviceModule.v1.SqlBackupRunsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1beta4.ts index e6f331aed7d4..31018716d40f 100644 --- a/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_backup_runs_service_v1beta4.ts @@ -19,957 +19,1215 @@ 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 sqlbackuprunsserviceModule from '../src'; -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 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('v1beta4.SqlBackupRunsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); - 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 = sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); + 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 = + sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient + .servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('has port', () => { - const port = sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - fallback: true, + 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + universeDomain: 'configured.example.com', }); - assert(client); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); - await client.initialize(); - assert(client.sqlBackupRunsServiceStub); + it('has port', () => { + const port = + sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlBackupRunsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); + await client.initialize(); + assert(client.sqlBackupRunsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlBackupRunsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlBackupRunsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', ['id']); - request.id = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); - }); - - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.BackupRun() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.BackupRun() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IBackupRun|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&id=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', ['id']); - request.id = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); - }); - - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); - }); - - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.BackupRunsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.BackupRunsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IBackupRunsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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('delete', () => { + it('invokes delete without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsDeleteRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ - 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('get', () => { + it('invokes get without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.BackupRun(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get 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 get without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.BackupRun(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IBackupRun | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&id=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsGetRequest', + ['id'], + ); + request.id = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.BackupRunsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.BackupRunsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IBackupRunsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with closed client', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlBackupRunsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlBackupRunsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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 sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqlbackuprunsserviceModule.v1beta4.SqlBackupRunsServiceClient({ + 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-sql/test/gapic_sql_backups_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_backups_service_v1.ts index 7cd5fd683143..e0e3601d826c 100644 --- a/packages/google-cloud-sql/test/gapic_sql_backups_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_backups_service_v1.ts @@ -19,1161 +19,1417 @@ 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 sqlbackupsserviceModule 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.SqlBackupsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); - 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 = sqlbackupsserviceModule.v1.SqlBackupsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlbackupsserviceModule.v1.SqlBackupsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('has universeDomain', () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + sqlbackupsserviceModule.v1.SqlBackupsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlbackupsserviceModule.v1.SqlBackupsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('has port', () => { - const port = sqlbackupsserviceModule.v1.SqlBackupsServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); - 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupsServiceStub, undefined); - await client.initialize(); - assert(client.sqlBackupsServiceStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlBackupsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = sqlbackupsserviceModule.v1.SqlBackupsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlBackupsServiceStub, undefined); + await client.initialize(); + assert(client.sqlBackupsServiceStub); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.createBackup = stubSimpleCall(expectedResponse); - const [response] = await client.createBackup(request); - 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('has close method for the initialized client', (done) => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlBackupsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createBackup without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.createBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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('has close method for the non-initialized client', (done) => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlBackupsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createBackup with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubSimpleCall(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('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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 createBackup with closed client', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createBackup(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.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('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.createBackup = stubSimpleCall(expectedResponse); + const [response] = await client.createBackup(request); + 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 getBackup without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.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 createBackup without error using callback', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.createBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 getBackup with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.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 createBackup with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubSimpleCall( + 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 getBackup with closed client', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.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 createBackup with closed client', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createBackup(request), expectedError); }); + }); - describe('updateBackup', () => { - it('invokes updateBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); - const [response] = await client.updateBackup(request); - 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('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.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 updateBackup without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.updateBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 getBackup without error using callback', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.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 updateBackup with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubSimpleCall(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 getBackup with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.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 updateBackup with closed client', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateBackup(request), expectedError); - }); + it('invokes getBackup with closed client', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.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('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); - const [response] = await client.deleteBackup(request); - 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('updateBackup', () => { + it('invokes updateBackup without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); + const [response] = await client.updateBackup(request); + 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 deleteBackup without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.deleteBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 updateBackup without error using callback', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.updateBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 deleteBackup with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubSimpleCall(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 updateBackup with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubSimpleCall( + 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 deleteBackup with closed client', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteBackup(request), expectedError); - }); + it('invokes updateBackup with closed client', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateBackup(request), expectedError); }); + }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.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)); - }); + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); + const [response] = await client.deleteBackup(request); + 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 listBackups without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.sql.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 deleteBackup without error using callback', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 listBackups with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.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 deleteBackup with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubSimpleCall( + 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 listBackupsStream without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.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.sql.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.sql.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 deleteBackup with closed client', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteBackup(request), expectedError); + }); + }); - it('invokes listBackupsStream with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.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.sql.v1.Backup[] = []; - stream.on('data', (response: protos.google.cloud.sql.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 - ) - ); - }); + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.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 listBackups without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.sql.v1.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackups without error using callback', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IBackup[] | 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 - ) - ); - }); + }, + ); + }); + 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('uses async iteration with listBackups with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.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.sql.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('invokes listBackups with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.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)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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 listBackupsStream without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.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.sql.v1.Backup[] = []; + stream.on('data', (response: protos.google.cloud.sql.v1.Backup) => { + responses.push(response); }); - it('invokes getLocation without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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)); + stream.on('end', () => { + resolve(responses); }); - it('invokes getLocation with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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)); + 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), + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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('invokes listBackupsStream with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.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.sql.v1.Backup[] = []; + stream.on('data', (response: protos.google.cloud.sql.v1.Backup) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); }); - it('uses async iteration with listLocations with error', async () => { - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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 - ) - ); + 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), + ); }); - describe('Path templates', () => { + it('uses async iteration with listBackups without error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.sql.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), + ); + }); - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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('uses async iteration with listBackups with error', async () => { + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.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.sql.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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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('backupPath', () => { - const result = client.backupPath("projectValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', 'backupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ - 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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new sqlbackupsserviceModule.v1.SqlBackupsServiceClient({ + 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('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + 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-sql/test/gapic_sql_backups_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_backups_service_v1beta4.ts index 7284e1063b10..b2fece3336d8 100644 --- a/packages/google-cloud-sql/test/gapic_sql_backups_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_backups_service_v1beta4.ts @@ -19,1161 +19,1465 @@ 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 sqlbackupsserviceModule 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('v1beta4.SqlBackupsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); + 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 = sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - fallback: true, - }); - assert(client); + it('should create a client with no option', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupsServiceStub, undefined); - await client.initialize(); - assert(client.sqlBackupsServiceStub); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlBackupsServiceStub, undefined); + await client.initialize(); + assert(client.sqlBackupsServiceStub); + }); - it('has close method for the initialized client', done => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlBackupsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlBackupsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlBackupsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlBackupsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.createBackup = stubSimpleCall(expectedResponse); - const [response] = await client.createBackup(request); - 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)); + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.createBackup = stubSimpleCall(expectedResponse); + const [response] = await client.createBackup(request); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.createBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.createBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubSimpleCall(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 error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubSimpleCall( + 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 closed client', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.CreateBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.CreateBackupRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createBackup(request), expectedError); + it('invokes createBackup with closed client', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.CreateBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.CreateBackupRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createBackup(request), expectedError); }); + }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.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('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Backup() - ); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.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 without error using callback', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Backup(), + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.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 error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.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 getBackup with closed client', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.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('updateBackup', () => { - it('invokes updateBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); - const [response] = await client.updateBackup(request); - 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('updateBackup', () => { + it('invokes updateBackup without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); + const [response] = await client.updateBackup(request); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.updateBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.updateBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubSimpleCall(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 error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedHeaderRequestParams = `backup.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubSimpleCall( + 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 closed client', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UpdateBackupRequest() - ); - request.backup ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.UpdateBackupRequest', ['backup', 'name']); - request.backup.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateBackup(request), expectedError); + it('invokes updateBackup with closed client', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UpdateBackupRequest(), + ); + request.backup ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.UpdateBackupRequest', + ['backup', 'name'], + ); + request.backup.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateBackup(request), expectedError); }); + }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); - const [response] = await client.deleteBackup(request); - 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); + const [response] = await client.deleteBackup(request); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.deleteBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.deleteBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubSimpleCall(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 error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubSimpleCall( + 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 closed client', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DeleteBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.DeleteBackupRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteBackup(request), expectedError); + it('invokes deleteBackup with closed client', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DeleteBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.DeleteBackupRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteBackup(request), expectedError); }); + }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.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)); + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.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 without error using callback', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.sql.v1beta4.Backup[] = []; - stream.on('data', (response: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.sql.v1beta4.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.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.sql.v1beta4.Backup[] = []; - stream.on('data', (response: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.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.sql.v1beta4.Backup[] = []; + stream.on( + 'data', + (response: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.ListBackupsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.ListBackupsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + generateSampleMessage(new protos.google.cloud.sql.v1beta4.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ListBackupsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.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.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ListBackupsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.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.sql.v1beta4.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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation without error using callback', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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)); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation with error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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)); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('uses async iteration with listLocations with error', async () => { - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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 - ) - ); + 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 sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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); - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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', 'backupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('backupPath', () => { - const result = client.backupPath("projectValue", "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('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - 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), + ); + }); + }); - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ + 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); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqlbackupsserviceModule.v1beta4.SqlBackupsServiceClient({ - 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('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('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-sql/test/gapic_sql_connect_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_connect_service_v1.ts index 6871c0b454df..b60949338fd6 100644 --- a/packages/google-cloud-sql/test/gapic_sql_connect_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_connect_service_v1.ts @@ -19,663 +19,823 @@ 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 sqlconnectserviceModule from '../src'; -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 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.SqlConnectServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); + 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 = sqlconnectserviceModule.v1.SqlConnectServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlconnectserviceModule.v1.SqlConnectServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlconnectserviceModule.v1.SqlConnectServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlconnectserviceModule.v1.SqlConnectServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlconnectserviceModule.v1.SqlConnectServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlconnectserviceModule.v1.SqlConnectServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlconnectserviceModule.v1.SqlConnectServiceClient({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 sqlconnectserviceModule.v1.SqlConnectServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = sqlconnectserviceModule.v1.SqlConnectServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 sqlconnectserviceModule.v1.SqlConnectServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.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 no option', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = sqlconnectserviceModule.v1.SqlConnectServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlConnectServiceStub, undefined); - await client.initialize(); - assert(client.sqlConnectServiceStub); - }); + it('should create a client with no option', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlConnectServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlConnectServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlConnectServiceStub, undefined); + await client.initialize(); + assert(client.sqlConnectServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlConnectServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlConnectServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getConnectSettings', () => { - it('invokes getConnectSettings without error', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.ConnectSettings() - ); - client.innerApiCalls.getConnectSettings = stubSimpleCall(expectedResponse); - const [response] = await client.getConnectSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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 getConnectSettings without error using callback', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.ConnectSettings() - ); - client.innerApiCalls.getConnectSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConnectSettings( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IConnectSettings|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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('getConnectSettings', () => { + it('invokes getConnectSettings without error', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.ConnectSettings(), + ); + client.innerApiCalls.getConnectSettings = + stubSimpleCall(expectedResponse); + const [response] = await client.getConnectSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getConnectSettings with error', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConnectSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConnectSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConnectSettings without error using callback', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.ConnectSettings(), + ); + client.innerApiCalls.getConnectSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConnectSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IConnectSettings | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getConnectSettings with closed client', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConnectSettings(request), expectedError); - }); + it('invokes getConnectSettings with error', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConnectSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getConnectSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateEphemeralCert', () => { - it('invokes generateEphemeralCert without error', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertResponse() - ); - client.innerApiCalls.generateEphemeralCert = stubSimpleCall(expectedResponse); - const [response] = await client.generateEphemeralCert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getConnectSettings with closed client', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConnectSettings(request), expectedError); + }); + }); + + describe('generateEphemeralCert', () => { + it('invokes generateEphemeralCert without error', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertResponse(), + ); + client.innerApiCalls.generateEphemeralCert = + stubSimpleCall(expectedResponse); + const [response] = await client.generateEphemeralCert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert without error using callback', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertResponse() - ); - client.innerApiCalls.generateEphemeralCert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateEphemeralCert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateEphemeralCert without error using callback', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertResponse(), + ); + client.innerApiCalls.generateEphemeralCert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateEphemeralCert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IGenerateEphemeralCertResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert with error', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateEphemeralCert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateEphemeralCert(request), expectedError); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes generateEphemeralCert with error', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateEphemeralCert = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateEphemeralCert(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert with closed client', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateEphemeralCert(request), expectedError); - }); + it('invokes generateEphemeralCert with closed client', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateEphemeralCert(request), + expectedError, + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ - 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", "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('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getLocation with error', async () => { + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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 sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlconnectserviceModule.v1.SqlConnectServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_connect_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_connect_service_v1beta4.ts index cf1df12ba74f..7a26e7c169f0 100644 --- a/packages/google-cloud-sql/test/gapic_sql_connect_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_connect_service_v1beta4.ts @@ -19,663 +19,849 @@ 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 sqlconnectserviceModule from '../src'; -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 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('v1beta4.SqlConnectServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); + 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 = sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlconnectserviceModule.v1beta4.SqlConnectServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlConnectServiceStub, undefined); - await client.initialize(); - assert(client.sqlConnectServiceStub); + it('should create a client with gRPC fallback', () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlConnectServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlConnectServiceStub, undefined); + await client.initialize(); + assert(client.sqlConnectServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlConnectServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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.initialize().catch((err) => { + throw err; + }); + assert(client.sqlConnectServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlConnectServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getConnectSettings', () => { - it('invokes getConnectSettings without error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ConnectSettings() - ); - client.innerApiCalls.getConnectSettings = stubSimpleCall(expectedResponse); - const [response] = await client.getConnectSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + 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 getConnectSettings without error using callback', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.ConnectSettings() - ); - client.innerApiCalls.getConnectSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getConnectSettings( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IConnectSettings|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + 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('getConnectSettings', () => { + it('invokes getConnectSettings without error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ConnectSettings(), + ); + client.innerApiCalls.getConnectSettings = + stubSimpleCall(expectedResponse); + const [response] = await client.getConnectSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getConnectSettings with error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getConnectSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getConnectSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getConnectSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes getConnectSettings without error using callback', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.ConnectSettings(), + ); + client.innerApiCalls.getConnectSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getConnectSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IConnectSettings | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getConnectSettings with closed client', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GetConnectSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getConnectSettings(request), expectedError); + it('invokes getConnectSettings with error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getConnectSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getConnectSettings(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getConnectSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('generateEphemeralCert', () => { - it('invokes generateEphemeralCert without error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse() - ); - client.innerApiCalls.generateEphemeralCert = stubSimpleCall(expectedResponse); - const [response] = await client.generateEphemeralCert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes getConnectSettings with closed client', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GetConnectSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GetConnectSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getConnectSettings(request), expectedError); + }); + }); + + describe('generateEphemeralCert', () => { + it('invokes generateEphemeralCert without error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse(), + ); + client.innerApiCalls.generateEphemeralCert = + stubSimpleCall(expectedResponse); + const [response] = await client.generateEphemeralCert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert without error using callback', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse() - ); - client.innerApiCalls.generateEphemeralCert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateEphemeralCert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes generateEphemeralCert without error using callback', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertResponse(), + ); + client.innerApiCalls.generateEphemeralCert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateEphemeralCert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IGenerateEphemeralCertResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert with error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.generateEphemeralCert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateEphemeralCert(request), expectedError); - const actualRequest = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.generateEphemeralCert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes generateEphemeralCert with error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.generateEphemeralCert = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.generateEphemeralCert(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.generateEphemeralCert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes generateEphemeralCert with closed client', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.generateEphemeralCert(request), expectedError); + it('invokes generateEphemeralCert with closed client', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.GenerateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.generateEphemeralCert(request), + expectedError, + ); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation without error using callback', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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)); + 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation with error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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)); + 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('uses async iteration with listLocations with error', async () => { - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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 - ) - ); + 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 sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ - 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", "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('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', + backup: 'backupValue', + }; + const client = + new sqlconnectserviceModule.v1beta4.SqlConnectServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_databases_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_databases_service_v1.ts index cca0b07a3c6e..15097fddb205 100644 --- a/packages/google-cloud-sql/test/gapic_sql_databases_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_databases_service_v1.ts @@ -19,1191 +19,1549 @@ 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 sqldatabasesserviceModule from '../src'; -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 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.SqlDatabasesServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); + 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 = sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqldatabasesserviceModule.v1.SqlDatabasesServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlDatabasesServiceStub, undefined); - await client.initialize(); - assert(client.sqlDatabasesServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlDatabasesServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlDatabasesServiceStub, undefined); + await client.initialize(); + assert(client.sqlDatabasesServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlDatabasesServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlDatabasesServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlDatabasesServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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 delete without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); + it('invokes delete with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Database() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - it('invokes get without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Database() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('get', () => { + it('invokes get without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Database(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Database(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IDatabase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); + it('invokes get with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); - it('invokes insert without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); + it('invokes insert with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.DatabasesListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); - it('invokes list without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.DatabasesListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IDatabasesListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('list', () => { + it('invokes list without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.DatabasesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.DatabasesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IDatabasesListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('patch', () => { - it('invokes patch without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.patch = stubSimpleCall(expectedResponse); - const [response] = await client.patch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); - it('invokes patch without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.patch( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes patch with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.patch(request), expectedError); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes patch without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes patch with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.patch(request), expectedError); - }); + it('invokes patch with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes patch with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.patch(request), expectedError); + }); + }); - it('invokes update without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('update', () => { + it('invokes update without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes update without error using callback', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with closed client', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); - }); + it('invokes update with error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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)); - }); + + it('invokes update with closed client', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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 sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient({ - 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); + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqldatabasesserviceModule.v1.SqlDatabasesServiceClient( + { + 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', '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('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + 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)); - }); - }); + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_databases_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_databases_service_v1beta4.ts index 888634ab0244..3f9edfa33005 100644 --- a/packages/google-cloud-sql/test/gapic_sql_databases_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_databases_service_v1beta4.ts @@ -19,1221 +19,1557 @@ 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 sqldatabasesserviceModule from '../src'; -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 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('v1beta4.SqlDatabasesServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); + 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 = sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient + .servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); - assert(client); - }); + it('has port', () => { + const port = + sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - fallback: true, - }); - assert(client); + it('should create a client with no option', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + fallback: true, }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlDatabasesServiceStub, undefined); - await client.initialize(); - assert(client.sqlDatabasesServiceStub); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlDatabasesServiceStub, undefined); + await client.initialize(); + assert(client.sqlDatabasesServiceStub); + }); - it('has close method for the initialized client', done => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlDatabasesServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlDatabasesServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has close method for the non-initialized client', done => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlDatabasesServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlDatabasesServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('delete', () => { + it('invokes delete without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes delete without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes delete with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); + it('invokes delete with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesDeleteRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); }); + }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Database() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('get', () => { + it('invokes get without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Database(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Database() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IDatabase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes get without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Database(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IDatabase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes get with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); + it('invokes get with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesGetRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); }); + }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('insert', () => { + it('invokes insert without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes insert without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes insert with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); + it('invokes insert with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); }); + }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DatabasesListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DatabasesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DatabasesListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IDatabasesListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes list without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DatabasesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IDatabasesListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes list with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); + it('invokes list with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); + }); - describe('patch', () => { - it('invokes patch without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.patch = stubSimpleCall(expectedResponse); - const [response] = await client.patch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('patch', () => { + it('invokes patch without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes patch without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.patch( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes patch without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes patch with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.patch(request), expectedError); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes patch with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes patch with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.patch(request), expectedError); + it('invokes patch with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.patch(request), expectedError); }); + }); - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('update', () => { + it('invokes update without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes update without error using callback', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&database=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes update with error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&database=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with closed client', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', ['database']); - request.database = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); + it('invokes update with closed client', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlDatabasesUpdateRequest', + ['database'], + ); + request.database = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation without error using callback', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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)); + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('invokes getLocation with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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)); + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - it('uses async iteration with listLocations with error', async () => { - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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 - ) - ); + 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 sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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); - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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', 'backupValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('backupPath', () => { - const result = client.backupPath("projectValue", "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('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - 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), + ); + }); + }); - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ + 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); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqldatabasesserviceModule.v1beta4.SqlDatabasesServiceClient({ - 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('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('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-sql/test/gapic_sql_feature_eligibility_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_feature_eligibility_service_v1.ts index 1b943f35d8e6..b8f469f7bc39 100644 --- a/packages/google-cloud-sql/test/gapic_sql_feature_eligibility_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_feature_eligibility_service_v1.ts @@ -19,419 +19,547 @@ 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 sqlfeatureeligibilityserviceModule from '../src'; -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 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.SqlFeatureEligibilityServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); + 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 = sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlfeatureeligibilityserviceModule.v1 + .SqlFeatureEligibilityServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlfeatureeligibilityserviceModule.v1 + .SqlFeatureEligibilityServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { universeDomain: 'configured.example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { universe_domain: 'example.com', universeDomain: 'example.net' }, + ); + }); + }); - it('should create a client with no option', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); - assert(client); - }); + it('has port', () => { + const port = + sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient + .port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFeatureEligibilityServiceStub, undefined); - await client.initialize(); - assert(client.sqlFeatureEligibilityServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlFeatureEligibilityServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlFeatureEligibilityServiceStub, undefined); + await client.initialize(); + assert(client.sqlFeatureEligibilityServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFeatureEligibilityServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlFeatureEligibilityServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlFeatureEligibilityServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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)); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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 sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient({ - 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); + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlfeatureeligibilityserviceModule.v1.SqlFeatureEligibilityServiceClient( + { + 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', '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('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + 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)); - }); - }); + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_flags_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_flags_service_v1.ts index be1385ccd329..09b5fbd0667f 100644 --- a/packages/google-cloud-sql/test/gapic_sql_flags_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_flags_service_v1.ts @@ -19,498 +19,591 @@ 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 sqlflagsserviceModule from '../src'; -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 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.SqlFlagsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); + 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 = sqlflagsserviceModule.v1.SqlFlagsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlflagsserviceModule.v1.SqlFlagsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlflagsserviceModule.v1.SqlFlagsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlflagsserviceModule.v1.SqlFlagsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlflagsserviceModule.v1.SqlFlagsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlflagsserviceModule.v1.SqlFlagsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlflagsserviceModule.v1.SqlFlagsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFlagsServiceStub, undefined); - await client.initialize(); - assert(client.sqlFlagsServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlFlagsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlFlagsServiceStub, undefined); + await client.initialize(); + assert(client.sqlFlagsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFlagsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlFlagsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlFlagsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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('list', () => { - it('invokes list without error', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlFlagsListRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.FlagsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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('list', () => { + it('invokes list without error', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlFlagsListRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.FlagsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes list without error using callback', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlFlagsListRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.FlagsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IFlagsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes list without error using callback', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlFlagsListRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.FlagsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IFlagsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes list with error', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlFlagsListRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlFlagsListRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + }); - it('invokes list with closed client', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlFlagsListRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with closed client', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlFlagsListRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ - 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", "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('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getLocation with error', async () => { + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlflagsserviceModule.v1.SqlFlagsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_flags_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_flags_service_v1beta4.ts index 0d1278673ccd..4e37b9e1b3e7 100644 --- a/packages/google-cloud-sql/test/gapic_sql_flags_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_flags_service_v1beta4.ts @@ -19,528 +19,631 @@ 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 sqlflagsserviceModule from '../src'; -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 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('v1beta4.SqlFlagsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); + 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 = sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFlagsServiceStub, undefined); - await client.initialize(); - assert(client.sqlFlagsServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlFlagsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlFlagsServiceStub, undefined); + await client.initialize(); + assert(client.sqlFlagsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlFlagsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlFlagsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlFlagsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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('list', () => { - it('invokes list without error', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.FlagsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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('list', () => { + it('invokes list without error', async () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.FlagsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes list without error using callback', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.FlagsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IFlagsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes list without error using callback', async () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.FlagsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IFlagsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes list with error', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + }); - it('invokes list with closed client', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with closed client', async () => { + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlFlagsListRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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', '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('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", - backup: "backupValue", - }; - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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", "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('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ - 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 sqlflagsserviceModule.v1beta4.SqlFlagsServiceClient({ + 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-sql/test/gapic_sql_instances_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_instances_service_v1.ts index 3e9991b4257f..03dbe2acbf28 100644 --- a/packages/google-cloud-sql/test/gapic_sql_instances_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_instances_service_v1.ts @@ -19,5609 +19,7460 @@ 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 sqlinstancesserviceModule from '../src'; -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 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.SqlInstancesServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); + 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 = sqlinstancesserviceModule.v1.SqlInstancesServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlinstancesserviceModule.v1.SqlInstancesServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlinstancesserviceModule.v1.SqlInstancesServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { universeDomain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlinstancesserviceModule.v1.SqlInstancesServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { universe_domain: 'example.com' }, + ); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has port', () => { + const port = sqlinstancesserviceModule.v1.SqlInstancesServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has port', () => { - const port = sqlinstancesserviceModule.v1.SqlInstancesServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('should create a client with no option', () => { + const client = + new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); + assert(client); + }); - it('should create a client with no option', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient(); - assert(client); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + fallback: true, + }, + ); + assert(client); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlInstancesServiceStub, undefined); + await client.initialize(); + assert(client.sqlInstancesServiceStub); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlInstancesServiceStub, undefined); - await client.initialize(); - assert(client.sqlInstancesServiceStub); + it('has close method for the initialized client', (done) => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlInstancesServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the initialized client', done => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlInstancesServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + assert.strictEqual(client.sqlInstancesServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlInstancesServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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('addServerCa', () => { + it('invokes addServerCa without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addServerCa = stubSimpleCall(expectedResponse); + const [response] = await client.addServerCa(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 addServerCa without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addServerCa = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addServerCa( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('addServerCa', () => { - it('invokes addServerCa without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addServerCa = stubSimpleCall(expectedResponse); - const [response] = await client.addServerCa(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addServerCa with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addServerCa = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.addServerCa(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCa without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addServerCa = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addServerCa( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addServerCa with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.addServerCa(request), expectedError); + }); + }); + + describe('addServerCertificate', () => { + it('invokes addServerCertificate without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addServerCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.addServerCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCa with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addServerCa = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addServerCa(request), expectedError); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addServerCertificate without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addServerCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addServerCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCa with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addServerCa(request), expectedError); - }); + it('invokes addServerCertificate with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addServerCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.addServerCertificate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('addServerCertificate', () => { - it('invokes addServerCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addServerCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.addServerCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addServerCertificate with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.addServerCertificate(request), expectedError); + }); + }); + + describe('addEntraIdCertificate', () => { + it('invokes addEntraIdCertificate without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addEntraIdCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.addEntraIdCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addServerCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addServerCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addEntraIdCertificate without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.addEntraIdCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addEntraIdCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addServerCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addServerCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes addEntraIdCertificate with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addEntraIdCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.addEntraIdCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addServerCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addServerCertificate(request), expectedError); - }); + it('invokes addEntraIdCertificate with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.addEntraIdCertificate(request), + expectedError, + ); + }); + }); + + describe('clone', () => { + it('invokes clone without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.clone = stubSimpleCall(expectedResponse); + const [response] = await client.clone(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('addEntraIdCertificate', () => { - it('invokes addEntraIdCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.addEntraIdCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes clone without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.clone = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.clone( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addEntraIdCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addEntraIdCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes clone with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.clone = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.clone(request), expectedError); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addEntraIdCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addEntraIdCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes clone with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.clone(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes addEntraIdCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addEntraIdCertificate(request), expectedError); - }); + it('invokes delete without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('clone', () => { - it('invokes clone without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.clone = stubSimpleCall(expectedResponse); - const [response] = await client.clone(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes clone without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.clone = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.clone( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('demoteMaster', () => { + it('invokes demoteMaster without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.demoteMaster = stubSimpleCall(expectedResponse); + const [response] = await client.demoteMaster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes clone with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.clone = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.clone(request), expectedError); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes demoteMaster without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.demoteMaster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.demoteMaster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes clone with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.clone(request), expectedError); - }); + it('invokes demoteMaster with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.demoteMaster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.demoteMaster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes demoteMaster with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.demoteMaster(request), expectedError); + }); + }); + + describe('demote', () => { + it('invokes demote without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.demote = stubSimpleCall(expectedResponse); + const [response] = await client.demote(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes demote without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.demote = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.demote( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes demote with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.demote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.demote(request), expectedError); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); + it('invokes demote with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.demote(request), expectedError); + }); + }); + + describe('export', () => { + it('invokes export without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.export = stubSimpleCall(expectedResponse); + const [response] = await client.export(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('demoteMaster', () => { - it('invokes demoteMaster without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.demoteMaster = stubSimpleCall(expectedResponse); - const [response] = await client.demoteMaster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes export without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.export = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.export( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demoteMaster without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.demoteMaster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.demoteMaster( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes export with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.export = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.export(request), expectedError); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demoteMaster with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.demoteMaster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.demoteMaster(request), expectedError); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes export with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.export(request), expectedError); + }); + }); + + describe('failover', () => { + it('invokes failover without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.failover = stubSimpleCall(expectedResponse); + const [response] = await client.failover(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demoteMaster with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.demoteMaster(request), expectedError); - }); + it('invokes failover without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.failover = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.failover( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('demote', () => { - it('invokes demote without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.demote = stubSimpleCall(expectedResponse); - const [response] = await client.demote(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes failover with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failover = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.failover(request), expectedError); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demote without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.demote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.demote( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes failover with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.failover(request), expectedError); + }); + }); + + describe('reencrypt', () => { + it('invokes reencrypt without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.reencrypt = stubSimpleCall(expectedResponse); + const [response] = await client.reencrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demote with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.demote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.demote(request), expectedError); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reencrypt without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.reencrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reencrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes demote with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.demote(request), expectedError); - }); + it('invokes reencrypt with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reencrypt = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.reencrypt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('export', () => { - it('invokes export without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.export = stubSimpleCall(expectedResponse); - const [response] = await client.export(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes reencrypt with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.reencrypt(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.DatabaseInstance(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes export without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.export = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.export( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.DatabaseInstance(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IDatabaseInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes export with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.export = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.export(request), expectedError); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes export with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.export(request), expectedError); - }); + it('invokes get with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('import', () => { + it('invokes import without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.import = stubSimpleCall(expectedResponse); + const [response] = await client.import(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('failover', () => { - it('invokes failover without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.failover = stubSimpleCall(expectedResponse); - const [response] = await client.failover(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes import without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.import = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.import( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes failover without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.failover = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.failover( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes import with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.import = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.import(request), expectedError); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes failover with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.failover = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.failover(request), expectedError); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes import with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.import(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes failover with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.failover(request), expectedError); - }); + it('invokes insert without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('reencrypt', () => { - it('invokes reencrypt without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.reencrypt = stubSimpleCall(expectedResponse); - const [response] = await client.reencrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reencrypt without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.reencrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reencrypt( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reencrypt with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reencrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.reencrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IInstancesListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes reencrypt with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.reencrypt(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.DatabaseInstance() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + + describe('listServerCas', () => { + it('invokes listServerCas without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListServerCasResponse(), + ); + client.innerApiCalls.listServerCas = stubSimpleCall(expectedResponse); + const [response] = await client.listServerCas(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.DatabaseInstance() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IDatabaseInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServerCas without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListServerCasResponse(), + ); + client.innerApiCalls.listServerCas = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerCas( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IInstancesListServerCasResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServerCas with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerCas = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServerCas(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); + it('invokes listServerCas with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.listServerCas(request), expectedError); + }); + }); + + describe('listServerCertificates', () => { + it('invokes listServerCertificates without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListServerCertificatesResponse(), + ); + client.innerApiCalls.listServerCertificates = + stubSimpleCall(expectedResponse); + const [response] = await client.listServerCertificates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('import', () => { - it('invokes import without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.import = stubSimpleCall(expectedResponse); - const [response] = await client.import(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServerCertificates without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListServerCertificatesResponse(), + ); + client.innerApiCalls.listServerCertificates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerCertificates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes import without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.import = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.import( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServerCertificates with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerCertificates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServerCertificates(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes import with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.import = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.import(request), expectedError); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listServerCertificates with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.listServerCertificates(request), + expectedError, + ); + }); + }); + + describe('listEntraIdCertificates', () => { + it('invokes listEntraIdCertificates without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListEntraIdCertificatesResponse(), + ); + client.innerApiCalls.listEntraIdCertificates = + stubSimpleCall(expectedResponse); + const [response] = await client.listEntraIdCertificates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes import with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.import(request), expectedError); - }); + it('invokes listEntraIdCertificates without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.InstancesListEntraIdCertificatesResponse(), + ); + client.innerApiCalls.listEntraIdCertificates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEntraIdCertificates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntraIdCertificates with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEntraIdCertificates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listEntraIdCertificates(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listEntraIdCertificates with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.listEntraIdCertificates(request), + expectedError, + ); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes patch without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); + it('invokes patch with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes patch with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('promoteReplica', () => { + it('invokes promoteReplica without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.promoteReplica = stubSimpleCall(expectedResponse); + const [response] = await client.promoteReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IInstancesListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes promoteReplica without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.promoteReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.promoteReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes promoteReplica with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.promoteReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.promoteReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes promoteReplica with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.promoteReplica(request), expectedError); + }); + }); + + describe('switchover', () => { + it('invokes switchover without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.switchover = stubSimpleCall(expectedResponse); + const [response] = await client.switchover(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listServerCas', () => { - it('invokes listServerCas without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListServerCasResponse() - ); - client.innerApiCalls.listServerCas = stubSimpleCall(expectedResponse); - const [response] = await client.listServerCas(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes switchover without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.switchover = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchover( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServerCas without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListServerCasResponse() - ); - client.innerApiCalls.listServerCas = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerCas( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IInstancesListServerCasResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes switchover with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchover = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.switchover(request), expectedError); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listServerCas with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerCas = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerCas(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCas with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listServerCas(request), expectedError); - }); + it('invokes switchover with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.switchover(request), expectedError); }); - - describe('listServerCertificates', () => { - it('invokes listServerCertificates without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListServerCertificatesResponse() - ); - client.innerApiCalls.listServerCertificates = stubSimpleCall(expectedResponse); - const [response] = await client.listServerCertificates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListServerCertificatesResponse() - ); - client.innerApiCalls.listServerCertificates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerCertificates( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IInstancesListServerCertificatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerCertificates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerCertificates(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listServerCertificates(request), expectedError); - }); + }); + + describe('resetSslConfig', () => { + it('invokes resetSslConfig without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.resetSslConfig = stubSimpleCall(expectedResponse); + const [response] = await client.resetSslConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listEntraIdCertificates', () => { - it('invokes listEntraIdCertificates without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListEntraIdCertificatesResponse() - ); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCall(expectedResponse); - const [response] = await client.listEntraIdCertificates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.InstancesListEntraIdCertificatesResponse() - ); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEntraIdCertificates( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IInstancesListEntraIdCertificatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEntraIdCertificates(request), expectedError); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listEntraIdCertificates(request), expectedError); - }); + it('invokes resetSslConfig without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.resetSslConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetSslConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('patch', () => { - it('invokes patch without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.patch = stubSimpleCall(expectedResponse); - const [response] = await client.patch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.patch( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.patch(request), expectedError); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.patch(request), expectedError); - }); + it('invokes resetSslConfig with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetSslConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetSslConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('promoteReplica', () => { - it('invokes promoteReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.promoteReplica = stubSimpleCall(expectedResponse); - const [response] = await client.promoteReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.promoteReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.promoteReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.promoteReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.promoteReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.promoteReplica(request), expectedError); - }); + it('invokes resetSslConfig with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resetSslConfig(request), expectedError); }); - - describe('switchover', () => { - it('invokes switchover without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.switchover = stubSimpleCall(expectedResponse); - const [response] = await client.switchover(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.switchover = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchover( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchover = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.switchover(request), expectedError); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.switchover(request), expectedError); - }); + }); + + describe('restart', () => { + it('invokes restart without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.restart = stubSimpleCall(expectedResponse); + const [response] = await client.restart(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetSslConfig', () => { - it('invokes resetSslConfig without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.resetSslConfig = stubSimpleCall(expectedResponse); - const [response] = await client.resetSslConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.resetSslConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetSslConfig( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetSslConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resetSslConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resetSslConfig(request), expectedError); - }); + it('invokes restart without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.restart = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restart( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restart', () => { - it('invokes restart without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.restart = stubSimpleCall(expectedResponse); - const [response] = await client.restart(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.restart = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restart( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restart = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.restart(request), expectedError); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.restart(request), expectedError); - }); + it('invokes restart with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restart = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.restart(request), expectedError); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('restoreBackup', () => { - it('invokes restoreBackup without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.restoreBackup = stubSimpleCall(expectedResponse); - const [response] = await client.restoreBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.restoreBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.restoreBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.restoreBackup(request), expectedError); - }); + it('invokes restart with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.restart(request), expectedError); }); - - describe('rotateServerCa', () => { - it('invokes rotateServerCa without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateServerCa = stubSimpleCall(expectedResponse); - const [response] = await client.rotateServerCa(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateServerCa = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateServerCa( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateServerCa = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateServerCa(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateServerCa(request), expectedError); - }); + }); + + describe('restoreBackup', () => { + it('invokes restoreBackup without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.restoreBackup = stubSimpleCall(expectedResponse); + const [response] = await client.restoreBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rotateServerCertificate', () => { - it('invokes rotateServerCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateServerCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.rotateServerCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateServerCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateServerCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateServerCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateServerCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateServerCertificate(request), expectedError); - }); + it('invokes restoreBackup without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.restoreBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('rotateEntraIdCertificate', () => { - it('invokes rotateEntraIdCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.rotateEntraIdCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateEntraIdCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateEntraIdCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateEntraIdCertificate(request), expectedError); - }); + it('invokes restoreBackup with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreBackup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startReplica', () => { - it('invokes startReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.startReplica = stubSimpleCall(expectedResponse); - const [response] = await client.startReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.startReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.startReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.startReplica(request), expectedError); - }); + it('invokes restoreBackup with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.restoreBackup(request), expectedError); }); - - describe('stopReplica', () => { - it('invokes stopReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.stopReplica = stubSimpleCall(expectedResponse); - const [response] = await client.stopReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.stopReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.stopReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.stopReplica(request), expectedError); - }); + }); + + describe('rotateServerCa', () => { + it('invokes rotateServerCa without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateServerCa = stubSimpleCall(expectedResponse); + const [response] = await client.rotateServerCa(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('truncateLog', () => { - it('invokes truncateLog without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.truncateLog = stubSimpleCall(expectedResponse); - const [response] = await client.truncateLog(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateServerCa without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateServerCa = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateServerCa( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes truncateLog without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.truncateLog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.truncateLog( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateServerCa with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateServerCa = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.rotateServerCa(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes truncateLog with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.truncateLog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.truncateLog(request), expectedError); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateServerCa with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.rotateServerCa(request), expectedError); + }); + }); + + describe('rotateServerCertificate', () => { + it('invokes rotateServerCertificate without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateServerCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.rotateServerCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes truncateLog with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.truncateLog(request), expectedError); - }); + it('invokes rotateServerCertificate without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateServerCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateServerCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateServerCertificate with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateServerCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rotateServerCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateServerCertificate with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rotateServerCertificate(request), + expectedError, + ); + }); + }); + + describe('rotateEntraIdCertificate', () => { + it('invokes rotateEntraIdCertificate without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateEntraIdCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.rotateEntraIdCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateEntraIdCertificate without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rotateEntraIdCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateEntraIdCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); - }); + it('invokes rotateEntraIdCertificate with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rotateEntraIdCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createEphemeral', () => { - it('invokes createEphemeral without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCert() - ); - client.innerApiCalls.createEphemeral = stubSimpleCall(expectedResponse); - const [response] = await client.createEphemeral(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rotateEntraIdCertificate with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rotateEntraIdCertificate(request), + expectedError, + ); + }); + }); + + describe('startReplica', () => { + it('invokes startReplica without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.startReplica = stubSimpleCall(expectedResponse); + const [response] = await client.startReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEphemeral without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCert() - ); - client.innerApiCalls.createEphemeral = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEphemeral( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISslCert|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startReplica without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.startReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEphemeral with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEphemeral = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createEphemeral(request), expectedError); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startReplica with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.startReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createEphemeral with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createEphemeral(request), expectedError); - }); + it('invokes startReplica with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.startReplica(request), expectedError); + }); + }); + + describe('stopReplica', () => { + it('invokes stopReplica without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.stopReplica = stubSimpleCall(expectedResponse); + const [response] = await client.stopReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCall(expectedResponse); - const [response] = await client.rescheduleMaintenance(request); - 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 stopReplica without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.stopReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 stopReplica with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCall(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 stopReplica with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.stopReplica(request), expectedError); + }); + }); + + describe('truncateLog', () => { + it('invokes truncateLog without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.truncateLog = stubSimpleCall(expectedResponse); + const [response] = await client.truncateLog(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes rescheduleMaintenance with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - }); + it('invokes truncateLog without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.truncateLog = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.truncateLog( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('verifyExternalSyncSettings', () => { - it('invokes verifyExternalSyncSettings without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse() - ); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall(expectedResponse); - const [response] = await client.verifyExternalSyncSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes truncateLog with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.truncateLog = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.truncateLog(request), expectedError); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyExternalSyncSettings without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse() - ); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.verifyExternalSyncSettings( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes truncateLog with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.truncateLog(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyExternalSyncSettings with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.verifyExternalSyncSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes update without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes verifyExternalSyncSettings with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.verifyExternalSyncSettings(request), expectedError); - }); + it('invokes update with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('startExternalSync', () => { - it('invokes startExternalSync without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.startExternalSync = stubSimpleCall(expectedResponse); - const [response] = await client.startExternalSync(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes update with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('createEphemeral', () => { + it('invokes createEphemeral without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCert(), + ); + client.innerApiCalls.createEphemeral = stubSimpleCall(expectedResponse); + const [response] = await client.createEphemeral(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startExternalSync without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.startExternalSync = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startExternalSync( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEphemeral without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCert(), + ); + client.innerApiCalls.createEphemeral = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEphemeral( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISslCert | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startExternalSync with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startExternalSync = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.startExternalSync(request), expectedError); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createEphemeral with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEphemeral = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEphemeral(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes startExternalSync with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.startExternalSync(request), expectedError); - }); + it('invokes createEphemeral with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createEphemeral(request), expectedError); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubSimpleCall(expectedResponse); + const [response] = await client.rescheduleMaintenance(request); + 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('performDiskShrink', () => { - it('invokes performDiskShrink without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.performDiskShrink = stubSimpleCall(expectedResponse); - const [response] = await client.performDiskShrink(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 performDiskShrink without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.performDiskShrink = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.performDiskShrink( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubSimpleCall( + 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 performDiskShrink with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.performDiskShrink = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.performDiskShrink(request), expectedError); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes rescheduleMaintenance with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rescheduleMaintenance(request), + expectedError, + ); + }); + }); + + describe('verifyExternalSyncSettings', () => { + it('invokes verifyExternalSyncSettings without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse(), + ); + client.innerApiCalls.verifyExternalSyncSettings = + stubSimpleCall(expectedResponse); + const [response] = await client.verifyExternalSyncSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes performDiskShrink with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.performDiskShrink(request), expectedError); - }); + it('invokes verifyExternalSyncSettings without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsResponse(), + ); + client.innerApiCalls.verifyExternalSyncSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.verifyExternalSyncSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesVerifyExternalSyncSettingsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getDiskShrinkConfig', () => { - it('invokes getDiskShrinkConfig without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigResponse() - ); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getDiskShrinkConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyExternalSyncSettings with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.verifyExternalSyncSettings(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDiskShrinkConfig without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigResponse() - ); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDiskShrinkConfig( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes verifyExternalSyncSettings with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.verifyExternalSyncSettings(request), + expectedError, + ); + }); + }); + + describe('startExternalSync', () => { + it('invokes startExternalSync without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.startExternalSync = stubSimpleCall(expectedResponse); + const [response] = await client.startExternalSync(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDiskShrinkConfig with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDiskShrinkConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startExternalSync without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.startExternalSync = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startExternalSync( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDiskShrinkConfig with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDiskShrinkConfig(request), expectedError); - }); + it('invokes startExternalSync with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startExternalSync = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.startExternalSync(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resetReplicaSize', () => { - it('invokes resetReplicaSize without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.resetReplicaSize = stubSimpleCall(expectedResponse); - const [response] = await client.resetReplicaSize(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes startExternalSync with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.startExternalSync(request), expectedError); + }); + }); + + describe('performDiskShrink', () => { + it('invokes performDiskShrink without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.performDiskShrink = stubSimpleCall(expectedResponse); + const [response] = await client.performDiskShrink(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetReplicaSize without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.resetReplicaSize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetReplicaSize( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes performDiskShrink without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.performDiskShrink = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.performDiskShrink( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetReplicaSize with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetReplicaSize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resetReplicaSize(request), expectedError); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes performDiskShrink with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.performDiskShrink = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.performDiskShrink(request), expectedError); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resetReplicaSize with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resetReplicaSize(request), expectedError); - }); + it('invokes performDiskShrink with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.performDiskShrink(request), expectedError); + }); + }); + + describe('getDiskShrinkConfig', () => { + it('invokes getDiskShrinkConfig without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigResponse(), + ); + client.innerApiCalls.getDiskShrinkConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getDiskShrinkConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLatestRecoveryTime', () => { - it('invokes getLatestRecoveryTime without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse() - ); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall(expectedResponse); - const [response] = await client.getLatestRecoveryTime(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDiskShrinkConfig without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigResponse(), + ); + client.innerApiCalls.getDiskShrinkConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDiskShrinkConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesGetDiskShrinkConfigResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getLatestRecoveryTime without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse() - ); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLatestRecoveryTime( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDiskShrinkConfig with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDiskShrinkConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getLatestRecoveryTime with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLatestRecoveryTime(request), expectedError); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDiskShrinkConfig with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDiskShrinkConfig(request), expectedError); + }); + }); + + describe('resetReplicaSize', () => { + it('invokes resetReplicaSize without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.resetReplicaSize = stubSimpleCall(expectedResponse); + const [response] = await client.resetReplicaSize(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getLatestRecoveryTime with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLatestRecoveryTime(request), expectedError); - }); + it('invokes resetReplicaSize without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.resetReplicaSize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetReplicaSize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('executeSql', () => { - it('invokes executeSql without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse() - ); - client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); - const [response] = await client.executeSql(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetReplicaSize with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetReplicaSize = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetReplicaSize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSql without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse() - ); - client.innerApiCalls.executeSql = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeSql( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resetReplicaSize with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resetReplicaSize(request), expectedError); + }); + }); + + describe('getLatestRecoveryTime', () => { + it('invokes getLatestRecoveryTime without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse(), + ); + client.innerApiCalls.getLatestRecoveryTime = + stubSimpleCall(expectedResponse); + const [response] = await client.getLatestRecoveryTime(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSql with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeSql = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeSql(request), expectedError); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLatestRecoveryTime without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeResponse(), + ); + client.innerApiCalls.getLatestRecoveryTime = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLatestRecoveryTime( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesGetLatestRecoveryTimeResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes executeSql with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeSql(request), expectedError); - }); + it('invokes getLatestRecoveryTime with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLatestRecoveryTime(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('acquireSsrsLease', () => { - it('invokes acquireSsrsLease without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse() - ); - client.innerApiCalls.acquireSsrsLease = stubSimpleCall(expectedResponse); - const [response] = await client.acquireSsrsLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getLatestRecoveryTime with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getLatestRecoveryTime(request), + expectedError, + ); + }); + }); + + describe('executeSql', () => { + it('invokes executeSql without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse(), + ); + client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); + const [response] = await client.executeSql(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acquireSsrsLease without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse() - ); - client.innerApiCalls.acquireSsrsLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acquireSsrsLease( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeSql without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlResponse(), + ); + client.innerApiCalls.executeSql = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeSql( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesExecuteSqlResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acquireSsrsLease with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acquireSsrsLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.acquireSsrsLease(request), expectedError); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes executeSql with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeSql = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeSql(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acquireSsrsLease with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.acquireSsrsLease(request), expectedError); - }); + it('invokes executeSql with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeSql(request), expectedError); + }); + }); + + describe('acquireSsrsLease', () => { + it('invokes acquireSsrsLease without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse(), + ); + client.innerApiCalls.acquireSsrsLease = stubSimpleCall(expectedResponse); + const [response] = await client.acquireSsrsLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('releaseSsrsLease', () => { - it('invokes releaseSsrsLease without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseResponse() - ); - client.innerApiCalls.releaseSsrsLease = stubSimpleCall(expectedResponse); - const [response] = await client.releaseSsrsLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acquireSsrsLease without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseResponse(), + ); + client.innerApiCalls.acquireSsrsLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acquireSsrsLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesAcquireSsrsLeaseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes releaseSsrsLease without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseResponse() - ); - client.innerApiCalls.releaseSsrsLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.releaseSsrsLease( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acquireSsrsLease with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acquireSsrsLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.acquireSsrsLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes releaseSsrsLease with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.releaseSsrsLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.releaseSsrsLease(request), expectedError); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acquireSsrsLease with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.acquireSsrsLease(request), expectedError); + }); + }); + + describe('releaseSsrsLease', () => { + it('invokes releaseSsrsLease without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseResponse(), + ); + client.innerApiCalls.releaseSsrsLease = stubSimpleCall(expectedResponse); + const [response] = await client.releaseSsrsLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes releaseSsrsLease with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.releaseSsrsLease(request), expectedError); - }); + it('invokes releaseSsrsLease without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseResponse(), + ); + client.innerApiCalls.releaseSsrsLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.releaseSsrsLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISqlInstancesReleaseSsrsLeaseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('preCheckMajorVersionUpgrade', () => { - it('invokes preCheckMajorVersionUpgrade without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall(expectedResponse); - const [response] = await client.preCheckMajorVersionUpgrade(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes releaseSsrsLease with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.releaseSsrsLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.releaseSsrsLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes preCheckMajorVersionUpgrade without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.preCheckMajorVersionUpgrade( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes releaseSsrsLease with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.releaseSsrsLease(request), expectedError); + }); + }); + + describe('preCheckMajorVersionUpgrade', () => { + it('invokes preCheckMajorVersionUpgrade without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.preCheckMajorVersionUpgrade = + stubSimpleCall(expectedResponse); + const [response] = await client.preCheckMajorVersionUpgrade(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes preCheckMajorVersionUpgrade with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.preCheckMajorVersionUpgrade(request), expectedError); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes preCheckMajorVersionUpgrade without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.preCheckMajorVersionUpgrade = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.preCheckMajorVersionUpgrade( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes preCheckMajorVersionUpgrade with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.preCheckMajorVersionUpgrade(request), expectedError); - }); + it('invokes preCheckMajorVersionUpgrade with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.preCheckMajorVersionUpgrade(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('pointInTimeRestore', () => { - it('invokes pointInTimeRestore without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.pointInTimeRestore = stubSimpleCall(expectedResponse); - const [response] = await client.pointInTimeRestore(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes preCheckMajorVersionUpgrade with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.preCheckMajorVersionUpgrade(request), + expectedError, + ); + }); + }); + + describe('pointInTimeRestore', () => { + it('invokes pointInTimeRestore without error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.pointInTimeRestore = + stubSimpleCall(expectedResponse); + const [response] = await client.pointInTimeRestore(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pointInTimeRestore without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.pointInTimeRestore = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pointInTimeRestore( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pointInTimeRestore without error using callback', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.pointInTimeRestore = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pointInTimeRestore( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pointInTimeRestore with error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.pointInTimeRestore = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pointInTimeRestore(request), expectedError); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pointInTimeRestore with error', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pointInTimeRestore = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.pointInTimeRestore(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pointInTimeRestore with closed client', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.pointInTimeRestore(request), expectedError); - }); + it('invokes pointInTimeRestore with closed client', async () => { + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }, + ); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.pointInTimeRestore(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + backupvault: 'backupvaultValue', + datasource: 'datasourceValue', + backup: 'backupValue', + }; + const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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', + 'datasourceValue', + '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('matchDatasourceFromBackupName', () => { + const result = client.matchDatasourceFromBackupName(fakePath); + assert.strictEqual(result, 'datasourceValue'); + 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", - backupvault: "backupvaultValue", - datasource: "datasourceValue", - backup: "backupValue", - }; - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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", "datasourceValue", "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('matchDatasourceFromBackupName', () => { - const result = client.matchDatasourceFromBackupName(fakePath); - assert.strictEqual(result, "datasourceValue"); - 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('network', async () => { - const fakePath = "/rendered/path/network"; - const expectedParameters = { - project: "projectValue", - network: "networkValue", - }; - const client = new sqlinstancesserviceModule.v1.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1.SqlInstancesServiceClient( + { + 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), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_instances_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_instances_service_v1beta4.ts index 5a2dbf876691..57ac7bbd95ca 100644 --- a/packages/google-cloud-sql/test/gapic_sql_instances_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_instances_service_v1beta4.ts @@ -19,5577 +19,7230 @@ 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 sqlinstancesserviceModule from '../src'; -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 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('v1beta4.SqlInstancesServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); - 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 = sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient.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 = + sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient + .servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlInstancesServiceStub, undefined); - await client.initialize(); - assert(client.sqlInstancesServiceStub); - }); + it('has port', () => { + const port = + sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlInstancesServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlInstancesServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlInstancesServiceStub, undefined); + await client.initialize(); + assert(client.sqlInstancesServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlInstancesServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlInstancesServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('addServerCa', () => { - it('invokes addServerCa without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addServerCa = stubSimpleCall(expectedResponse); - const [response] = await client.addServerCa(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCa without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addServerCa = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addServerCa( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCa with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addServerCa = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addServerCa(request), expectedError); - const actualRequest = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCa with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addServerCa(request), expectedError); - }); - }); - - describe('addServerCertificate', () => { - it('invokes addServerCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addServerCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.addServerCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addServerCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addServerCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addServerCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addServerCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addServerCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addServerCertificate(request), expectedError); - }); - }); - - describe('addEntraIdCertificate', () => { - it('invokes addEntraIdCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.addEntraIdCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addEntraIdCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.addEntraIdCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addEntraIdCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.addEntraIdCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.addEntraIdCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.addEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes addEntraIdCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.addEntraIdCertificate(request), expectedError); - }); - }); - - describe('clone', () => { - it('invokes clone without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.clone = stubSimpleCall(expectedResponse); - const [response] = await client.clone(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes clone without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.clone = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.clone( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes clone with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.clone = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.clone(request), expectedError); - const actualRequest = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.clone as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes clone with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.clone(request), expectedError); - }); - }); - - describe('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); - }); - - describe('demoteMaster', () => { - it('invokes demoteMaster without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.demoteMaster = stubSimpleCall(expectedResponse); - const [response] = await client.demoteMaster(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demoteMaster without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.demoteMaster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.demoteMaster( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demoteMaster with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.demoteMaster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.demoteMaster(request), expectedError); - const actualRequest = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demoteMaster as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demoteMaster with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.demoteMaster(request), expectedError); - }); - }); - - describe('demote', () => { - it('invokes demote without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.demote = stubSimpleCall(expectedResponse); - const [response] = await client.demote(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demote without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.demote = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.demote( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demote with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.demote = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.demote(request), expectedError); - const actualRequest = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.demote as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes demote with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.demote(request), expectedError); - }); - }); - - describe('export', () => { - it('invokes export without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.export = stubSimpleCall(expectedResponse); - const [response] = await client.export(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes export without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.export = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.export( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes export with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.export = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.export(request), expectedError); - const actualRequest = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.export as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes export with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExportRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.export(request), expectedError); - }); - }); - - describe('failover', () => { - it('invokes failover without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.failover = stubSimpleCall(expectedResponse); - const [response] = await client.failover(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failover without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.failover = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.failover( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failover with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.failover = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.failover(request), expectedError); - const actualRequest = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.failover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes failover with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.failover(request), expectedError); - }); - }); - - describe('reencrypt', () => { - it('invokes reencrypt without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.reencrypt = stubSimpleCall(expectedResponse); - const [response] = await client.reencrypt(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reencrypt without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.reencrypt = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.reencrypt( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reencrypt with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.reencrypt = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.reencrypt(request), expectedError); - const actualRequest = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.reencrypt as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes reencrypt with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.reencrypt(request), expectedError); - }); - }); - - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DatabaseInstance() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.DatabaseInstance() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IDatabaseInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); - }); - - describe('import', () => { - it('invokes import without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.import = stubSimpleCall(expectedResponse); - const [response] = await client.import(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes import without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.import = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.import( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes import with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.import = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.import(request), expectedError); - const actualRequest = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.import as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes import with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesImportRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.import(request), expectedError); - }); - }); - - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); - }); - - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IInstancesListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); - }); - - describe('listServerCas', () => { - it('invokes listServerCas without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListServerCasResponse() - ); - client.innerApiCalls.listServerCas = stubSimpleCall(expectedResponse); - const [response] = await client.listServerCas(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCas without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListServerCasResponse() - ); - client.innerApiCalls.listServerCas = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerCas( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCas with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerCas = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerCas(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCas as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCas with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listServerCas(request), expectedError); - }); - }); - - describe('listServerCertificates', () => { - it('invokes listServerCertificates without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListServerCertificatesResponse() - ); - client.innerApiCalls.listServerCertificates = stubSimpleCall(expectedResponse); - const [response] = await client.listServerCertificates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListServerCertificatesResponse() - ); - client.innerApiCalls.listServerCertificates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listServerCertificates( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listServerCertificates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listServerCertificates(request), expectedError); - const actualRequest = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listServerCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listServerCertificates with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listServerCertificates(request), expectedError); - }); - }); - - describe('listEntraIdCertificates', () => { - it('invokes listEntraIdCertificates without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListEntraIdCertificatesResponse() - ); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCall(expectedResponse); - const [response] = await client.listEntraIdCertificates(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.InstancesListEntraIdCertificatesResponse() - ); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listEntraIdCertificates( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listEntraIdCertificates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listEntraIdCertificates(request), expectedError); - const actualRequest = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listEntraIdCertificates as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listEntraIdCertificates with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.listEntraIdCertificates(request), expectedError); - }); - }); - - describe('patch', () => { - it('invokes patch without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.patch = stubSimpleCall(expectedResponse); - const [response] = await client.patch(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.patch( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.patch(request), expectedError); - const actualRequest = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.patch as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes patch with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.patch(request), expectedError); - }); - }); - - describe('promoteReplica', () => { - it('invokes promoteReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.promoteReplica = stubSimpleCall(expectedResponse); - const [response] = await client.promoteReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.promoteReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.promoteReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.promoteReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.promoteReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.promoteReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes promoteReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.promoteReplica(request), expectedError); - }); - }); - - describe('switchover', () => { - it('invokes switchover without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.switchover = stubSimpleCall(expectedResponse); - const [response] = await client.switchover(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.switchover = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.switchover( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.switchover = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.switchover(request), expectedError); - const actualRequest = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.switchover as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes switchover with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.switchover(request), expectedError); - }); - }); - - describe('resetSslConfig', () => { - it('invokes resetSslConfig without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.resetSslConfig = stubSimpleCall(expectedResponse); - const [response] = await client.resetSslConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.resetSslConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetSslConfig( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetSslConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resetSslConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetSslConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetSslConfig with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resetSslConfig(request), expectedError); - }); - }); - - describe('restart', () => { - it('invokes restart without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.restart = stubSimpleCall(expectedResponse); - const [response] = await client.restart(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.restart = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restart( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restart = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.restart(request), expectedError); - const actualRequest = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restart as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restart with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.restart(request), expectedError); - }); - }); - - describe('restoreBackup', () => { - it('invokes restoreBackup without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.restoreBackup = stubSimpleCall(expectedResponse); - const [response] = await client.restoreBackup(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.restoreBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreBackup( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.restoreBackup(request), expectedError); - const actualRequest = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.restoreBackup as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes restoreBackup with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.restoreBackup(request), expectedError); - }); - }); - - describe('rotateServerCa', () => { - it('invokes rotateServerCa without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateServerCa = stubSimpleCall(expectedResponse); - const [response] = await client.rotateServerCa(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateServerCa = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateServerCa( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateServerCa = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateServerCa(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCa as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCa with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateServerCa(request), expectedError); - }); - }); - - describe('rotateServerCertificate', () => { - it('invokes rotateServerCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateServerCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.rotateServerCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateServerCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateServerCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateServerCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateServerCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateServerCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateServerCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateServerCertificate(request), expectedError); - }); - }); - - describe('rotateEntraIdCertificate', () => { - it('invokes rotateEntraIdCertificate without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall(expectedResponse); - const [response] = await client.rotateEntraIdCertificate(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rotateEntraIdCertificate( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.rotateEntraIdCertificate(request), expectedError); - const actualRequest = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.rotateEntraIdCertificate as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes rotateEntraIdCertificate with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rotateEntraIdCertificate(request), expectedError); - }); - }); - - describe('startReplica', () => { - it('invokes startReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.startReplica = stubSimpleCall(expectedResponse); - const [response] = await client.startReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.startReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.startReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.startReplica(request), expectedError); - }); - }); - - describe('stopReplica', () => { - it('invokes stopReplica without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.stopReplica = stubSimpleCall(expectedResponse); - const [response] = await client.stopReplica(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.stopReplica = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.stopReplica( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.stopReplica = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.stopReplica(request), expectedError); - const actualRequest = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.stopReplica as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes stopReplica with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.stopReplica(request), expectedError); - }); - }); - - describe('truncateLog', () => { - it('invokes truncateLog without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.truncateLog = stubSimpleCall(expectedResponse); - const [response] = await client.truncateLog(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes truncateLog without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.truncateLog = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.truncateLog( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes truncateLog with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.truncateLog = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.truncateLog(request), expectedError); - const actualRequest = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.truncateLog as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes truncateLog with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.truncateLog(request), expectedError); - }); - }); - - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes update without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes update with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes update with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); - }); - }); - - describe('createEphemeral', () => { - it('invokes createEphemeral without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCert() - ); - client.innerApiCalls.createEphemeral = stubSimpleCall(expectedResponse); - const [response] = await client.createEphemeral(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEphemeral without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCert() - ); - client.innerApiCalls.createEphemeral = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createEphemeral( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISslCert|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEphemeral with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createEphemeral = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createEphemeral(request), expectedError); - const actualRequest = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createEphemeral as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createEphemeral with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createEphemeral(request), expectedError); - }); - }); - - describe('rescheduleMaintenance', () => { - it('invokes rescheduleMaintenance without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCall(expectedResponse); - const [response] = await client.rescheduleMaintenance(request); - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.rescheduleMaintenance( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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 error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.rescheduleMaintenance = stubSimpleCall(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 closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.rescheduleMaintenance(request), expectedError); - }); - }); - - describe('verifyExternalSyncSettings', () => { - it('invokes verifyExternalSyncSettings without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse() - ); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall(expectedResponse); - const [response] = await client.verifyExternalSyncSettings(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes verifyExternalSyncSettings without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse() - ); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.verifyExternalSyncSettings( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes verifyExternalSyncSettings with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.verifyExternalSyncSettings(request), expectedError); - const actualRequest = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.verifyExternalSyncSettings as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes verifyExternalSyncSettings with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.verifyExternalSyncSettings(request), expectedError); - }); - }); - - describe('startExternalSync', () => { - it('invokes startExternalSync without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.startExternalSync = stubSimpleCall(expectedResponse); - const [response] = await client.startExternalSync(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startExternalSync without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.startExternalSync = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.startExternalSync( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startExternalSync with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.startExternalSync = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.startExternalSync(request), expectedError); - const actualRequest = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.startExternalSync as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes startExternalSync with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.startExternalSync(request), expectedError); - }); - }); - - describe('performDiskShrink', () => { - it('invokes performDiskShrink without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.performDiskShrink = stubSimpleCall(expectedResponse); - const [response] = await client.performDiskShrink(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes performDiskShrink without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.performDiskShrink = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.performDiskShrink( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes performDiskShrink with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.performDiskShrink = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.performDiskShrink(request), expectedError); - const actualRequest = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.performDiskShrink as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes performDiskShrink with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.performDiskShrink(request), expectedError); - }); - }); - - describe('getDiskShrinkConfig', () => { - it('invokes getDiskShrinkConfig without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse() - ); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getDiskShrinkConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDiskShrinkConfig without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse() - ); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDiskShrinkConfig( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDiskShrinkConfig with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDiskShrinkConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDiskShrinkConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getDiskShrinkConfig with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDiskShrinkConfig(request), expectedError); - }); - }); - - describe('resetReplicaSize', () => { - it('invokes resetReplicaSize without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.resetReplicaSize = stubSimpleCall(expectedResponse); - const [response] = await client.resetReplicaSize(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetReplicaSize without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.resetReplicaSize = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resetReplicaSize( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetReplicaSize with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resetReplicaSize = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resetReplicaSize(request), expectedError); - const actualRequest = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resetReplicaSize as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes resetReplicaSize with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resetReplicaSize(request), expectedError); - }); - }); - - describe('getLatestRecoveryTime', () => { - it('invokes getLatestRecoveryTime without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse() - ); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall(expectedResponse); - const [response] = await client.getLatestRecoveryTime(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLatestRecoveryTime without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse() - ); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLatestRecoveryTime( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLatestRecoveryTime with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLatestRecoveryTime(request), expectedError); - const actualRequest = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getLatestRecoveryTime as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getLatestRecoveryTime with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getLatestRecoveryTime(request), expectedError); - }); - }); - - describe('executeSql', () => { - it('invokes executeSql without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse() - ); - client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); - const [response] = await client.executeSql(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse() - ); - client.innerApiCalls.executeSql = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.executeSql( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.executeSql = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.executeSql(request), expectedError); - const actualRequest = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.executeSql as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes executeSql with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.executeSql(request), expectedError); - }); - }); - - describe('acquireSsrsLease', () => { - it('invokes acquireSsrsLease without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse() - ); - client.innerApiCalls.acquireSsrsLease = stubSimpleCall(expectedResponse); - const [response] = await client.acquireSsrsLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes acquireSsrsLease without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse() - ); - client.innerApiCalls.acquireSsrsLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acquireSsrsLease( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes acquireSsrsLease with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acquireSsrsLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.acquireSsrsLease(request), expectedError); - const actualRequest = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acquireSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes acquireSsrsLease with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.acquireSsrsLease(request), expectedError); - }); - }); - - describe('releaseSsrsLease', () => { - it('invokes releaseSsrsLease without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse() - ); - client.innerApiCalls.releaseSsrsLease = stubSimpleCall(expectedResponse); - const [response] = await client.releaseSsrsLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes releaseSsrsLease without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse() - ); - client.innerApiCalls.releaseSsrsLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.releaseSsrsLease( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes releaseSsrsLease with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.releaseSsrsLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.releaseSsrsLease(request), expectedError); - const actualRequest = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.releaseSsrsLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes releaseSsrsLease with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.releaseSsrsLease(request), expectedError); - }); - }); - - describe('preCheckMajorVersionUpgrade', () => { - it('invokes preCheckMajorVersionUpgrade without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall(expectedResponse); - const [response] = await client.preCheckMajorVersionUpgrade(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes preCheckMajorVersionUpgrade without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.preCheckMajorVersionUpgrade( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes preCheckMajorVersionUpgrade with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.preCheckMajorVersionUpgrade(request), expectedError); - const actualRequest = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes preCheckMajorVersionUpgrade with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.preCheckMajorVersionUpgrade(request), expectedError); - }); - }); - - describe('pointInTimeRestore', () => { - it('invokes pointInTimeRestore without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.pointInTimeRestore = stubSimpleCall(expectedResponse); - const [response] = await client.pointInTimeRestore(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pointInTimeRestore without error using callback', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.pointInTimeRestore = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pointInTimeRestore( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pointInTimeRestore with error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.pointInTimeRestore = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pointInTimeRestore(request), expectedError); - const actualRequest = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pointInTimeRestore as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes pointInTimeRestore with closed client', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.pointInTimeRestore(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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('addServerCa', () => { + it('invokes addServerCa without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addServerCa = stubSimpleCall(expectedResponse); + const [response] = await client.addServerCa(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa 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 addServerCa without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addServerCa = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addServerCa( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ - 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 addServerCa with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addServerCa = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.addServerCa(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCa 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 addServerCa with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.addServerCa(request), expectedError); + }); + }); + + describe('addServerCertificate', () => { + it('invokes addServerCertificate without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addServerCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.addServerCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addServerCertificate without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addServerCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addServerCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addServerCertificate with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addServerCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.addServerCertificate(request), expectedError); + const actualRequest = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addServerCertificate with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.addServerCertificate(request), expectedError); + }); + }); + + describe('addEntraIdCertificate', () => { + it('invokes addEntraIdCertificate without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addEntraIdCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.addEntraIdCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addEntraIdCertificate without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.addEntraIdCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.addEntraIdCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addEntraIdCertificate with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.addEntraIdCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.addEntraIdCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.addEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes addEntraIdCertificate with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAddEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.addEntraIdCertificate(request), + expectedError, + ); + }); + }); + + describe('clone', () => { + it('invokes clone without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.clone = stubSimpleCall(expectedResponse); + const [response] = await client.clone(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes clone without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.clone = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.clone( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes clone with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.clone = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.clone(request), expectedError); + const actualRequest = (client.innerApiCalls.clone as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.clone as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes clone with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCloneRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCloneRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.clone(request), expectedError); + }); + }); + + describe('delete', () => { + it('invokes delete without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); + + describe('demoteMaster', () => { + it('invokes demoteMaster without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.demoteMaster = stubSimpleCall(expectedResponse); + const [response] = await client.demoteMaster(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demoteMaster without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.demoteMaster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.demoteMaster( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demoteMaster with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.demoteMaster = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.demoteMaster(request), expectedError); + const actualRequest = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demoteMaster as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demoteMaster with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteMasterRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.demoteMaster(request), expectedError); + }); + }); + + describe('demote', () => { + it('invokes demote without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.demote = stubSimpleCall(expectedResponse); + const [response] = await client.demote(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demote without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.demote = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.demote( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demote with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.demote = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.demote(request), expectedError); + const actualRequest = (client.innerApiCalls.demote as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.demote as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes demote with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesDemoteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.demote(request), expectedError); + }); + }); + + describe('export', () => { + it('invokes export without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.export = stubSimpleCall(expectedResponse); + const [response] = await client.export(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes export without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.export = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.export( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes export with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.export = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.export(request), expectedError); + const actualRequest = (client.innerApiCalls.export as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.export as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes export with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.export(request), expectedError); + }); + }); + + describe('failover', () => { + it('invokes failover without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.failover = stubSimpleCall(expectedResponse); + const [response] = await client.failover(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failover without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.failover = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.failover( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failover with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.failover = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.failover(request), expectedError); + const actualRequest = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.failover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes failover with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesFailoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.failover(request), expectedError); + }); + }); + + describe('reencrypt', () => { + it('invokes reencrypt without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.reencrypt = stubSimpleCall(expectedResponse); + const [response] = await client.reencrypt(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reencrypt without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.reencrypt = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reencrypt( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reencrypt with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.reencrypt = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.reencrypt(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reencrypt as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reencrypt with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReencryptRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.reencrypt(request), expectedError); + }); + }); + + describe('get', () => { + it('invokes get without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DatabaseInstance(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.DatabaseInstance(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IDatabaseInstance | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('import', () => { + it('invokes import without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.import = stubSimpleCall(expectedResponse); + const [response] = await client.import(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes import without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.import = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.import( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes import with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.import = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.import(request), expectedError); + const actualRequest = (client.innerApiCalls.import as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.import as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes import with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesImportRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesImportRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.import(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IInstancesListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + + describe('listServerCas', () => { + it('invokes listServerCas without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListServerCasResponse(), + ); + client.innerApiCalls.listServerCas = stubSimpleCall(expectedResponse); + const [response] = await client.listServerCas(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCas without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListServerCasResponse(), + ); + client.innerApiCalls.listServerCas = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerCas( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IInstancesListServerCasResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCas with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerCas = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listServerCas(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCas as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCas with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCasRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.listServerCas(request), expectedError); + }); + }); + + describe('listServerCertificates', () => { + it('invokes listServerCertificates without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListServerCertificatesResponse(), + ); + client.innerApiCalls.listServerCertificates = + stubSimpleCall(expectedResponse); + const [response] = await client.listServerCertificates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCertificates without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListServerCertificatesResponse(), + ); + client.innerApiCalls.listServerCertificates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listServerCertificates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IInstancesListServerCertificatesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCertificates with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listServerCertificates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listServerCertificates(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listServerCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listServerCertificates with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListServerCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.listServerCertificates(request), + expectedError, + ); + }); + }); + + describe('listEntraIdCertificates', () => { + it('invokes listEntraIdCertificates without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListEntraIdCertificatesResponse(), + ); + client.innerApiCalls.listEntraIdCertificates = + stubSimpleCall(expectedResponse); + const [response] = await client.listEntraIdCertificates(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEntraIdCertificates without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.InstancesListEntraIdCertificatesResponse(), + ); + client.innerApiCalls.listEntraIdCertificates = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listEntraIdCertificates( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IInstancesListEntraIdCertificatesResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEntraIdCertificates with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listEntraIdCertificates = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.listEntraIdCertificates(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listEntraIdCertificates as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listEntraIdCertificates with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesListEntraIdCertificatesRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.listEntraIdCertificates(request), + expectedError, + ); + }); + }); + + describe('patch', () => { + it('invokes patch without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCall(expectedResponse); + const [response] = await client.patch(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.patch = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.patch( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.patch = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.patch(request), expectedError); + const actualRequest = (client.innerApiCalls.patch as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.patch as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes patch with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPatchRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPatchRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.patch(request), expectedError); + }); + }); + + describe('promoteReplica', () => { + it('invokes promoteReplica without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.promoteReplica = stubSimpleCall(expectedResponse); + const [response] = await client.promoteReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes promoteReplica without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.promoteReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.promoteReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes promoteReplica with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.promoteReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.promoteReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.promoteReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes promoteReplica with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPromoteReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.promoteReplica(request), expectedError); + }); + }); + + describe('switchover', () => { + it('invokes switchover without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.switchover = stubSimpleCall(expectedResponse); + const [response] = await client.switchover(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchover without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.switchover = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.switchover( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchover with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.switchover = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.switchover(request), expectedError); + const actualRequest = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.switchover as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes switchover with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesSwitchoverRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.switchover(request), expectedError); + }); + }); + + describe('resetSslConfig', () => { + it('invokes resetSslConfig without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.resetSslConfig = stubSimpleCall(expectedResponse); + const [response] = await client.resetSslConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetSslConfig without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.resetSslConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetSslConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetSslConfig with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetSslConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetSslConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetSslConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetSslConfig with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetSslConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resetSslConfig(request), expectedError); + }); + }); + + describe('restart', () => { + it('invokes restart without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.restart = stubSimpleCall(expectedResponse); + const [response] = await client.restart(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restart without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.restart = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restart( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restart with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restart = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.restart(request), expectedError); + const actualRequest = (client.innerApiCalls.restart as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restart as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restart with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestartRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestartRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.restart(request), expectedError); + }); + }); + + describe('restoreBackup', () => { + it('invokes restoreBackup without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.restoreBackup = stubSimpleCall(expectedResponse); + const [response] = await client.restoreBackup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreBackup without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.restoreBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreBackup( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreBackup with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreBackup = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.restoreBackup(request), expectedError); + const actualRequest = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.restoreBackup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes restoreBackup with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRestoreBackupRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.restoreBackup(request), expectedError); + }); + }); + + describe('rotateServerCa', () => { + it('invokes rotateServerCa without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateServerCa = stubSimpleCall(expectedResponse); + const [response] = await client.rotateServerCa(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCa without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateServerCa = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateServerCa( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCa with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateServerCa = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.rotateServerCa(request), expectedError); + const actualRequest = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCa as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCa with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.rotateServerCa(request), expectedError); + }); + }); + + describe('rotateServerCertificate', () => { + it('invokes rotateServerCertificate without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateServerCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.rotateServerCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCertificate without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateServerCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateServerCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCertificate with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateServerCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rotateServerCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateServerCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateServerCertificate with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateServerCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rotateServerCertificate(request), + expectedError, + ); + }); + }); + + describe('rotateEntraIdCertificate', () => { + it('invokes rotateEntraIdCertificate without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateEntraIdCertificate = + stubSimpleCall(expectedResponse); + const [response] = await client.rotateEntraIdCertificate(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateEntraIdCertificate without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rotateEntraIdCertificate = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rotateEntraIdCertificate( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateEntraIdCertificate with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rotateEntraIdCertificate = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.rotateEntraIdCertificate(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.rotateEntraIdCertificate as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes rotateEntraIdCertificate with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRotateEntraIdCertificateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rotateEntraIdCertificate(request), + expectedError, + ); + }); + }); + + describe('startReplica', () => { + it('invokes startReplica without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.startReplica = stubSimpleCall(expectedResponse); + const [response] = await client.startReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startReplica without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.startReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startReplica with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.startReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startReplica with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.startReplica(request), expectedError); + }); + }); + + describe('stopReplica', () => { + it('invokes stopReplica without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.stopReplica = stubSimpleCall(expectedResponse); + const [response] = await client.stopReplica(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopReplica without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.stopReplica = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.stopReplica( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopReplica with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.stopReplica = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.stopReplica(request), expectedError); + const actualRequest = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.stopReplica as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes stopReplica with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStopReplicaRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.stopReplica(request), expectedError); + }); + }); + + describe('truncateLog', () => { + it('invokes truncateLog without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.truncateLog = stubSimpleCall(expectedResponse); + const [response] = await client.truncateLog(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes truncateLog without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.truncateLog = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.truncateLog( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes truncateLog with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.truncateLog = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.truncateLog(request), expectedError); + const actualRequest = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.truncateLog as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes truncateLog with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesTruncateLogRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.truncateLog(request), expectedError); + }); + }); + + describe('update', () => { + it('invokes update without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); + }); + }); + + describe('createEphemeral', () => { + it('invokes createEphemeral without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCert(), + ); + client.innerApiCalls.createEphemeral = stubSimpleCall(expectedResponse); + const [response] = await client.createEphemeral(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEphemeral without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCert(), + ); + client.innerApiCalls.createEphemeral = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createEphemeral( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISslCert | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEphemeral with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createEphemeral = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createEphemeral(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createEphemeral as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createEphemeral with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesCreateEphemeralCertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createEphemeral(request), expectedError); + }); + }); + + describe('rescheduleMaintenance', () => { + it('invokes rescheduleMaintenance without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubSimpleCall(expectedResponse); + const [response] = await client.rescheduleMaintenance(request); + 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.rescheduleMaintenance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rescheduleMaintenance( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.rescheduleMaintenance = stubSimpleCall( + 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 closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesRescheduleMaintenanceRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.rescheduleMaintenance(request), + expectedError, + ); + }); + }); + + describe('verifyExternalSyncSettings', () => { + it('invokes verifyExternalSyncSettings without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse(), + ); + client.innerApiCalls.verifyExternalSyncSettings = + stubSimpleCall(expectedResponse); + const [response] = await client.verifyExternalSyncSettings(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes verifyExternalSyncSettings without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsResponse(), + ); + client.innerApiCalls.verifyExternalSyncSettings = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.verifyExternalSyncSettings( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesVerifyExternalSyncSettingsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes verifyExternalSyncSettings with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.verifyExternalSyncSettings = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.verifyExternalSyncSettings(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.verifyExternalSyncSettings as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes verifyExternalSyncSettings with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesVerifyExternalSyncSettingsRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.verifyExternalSyncSettings(request), + expectedError, + ); + }); + }); + + describe('startExternalSync', () => { + it('invokes startExternalSync without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.startExternalSync = stubSimpleCall(expectedResponse); + const [response] = await client.startExternalSync(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startExternalSync without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.startExternalSync = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.startExternalSync( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startExternalSync with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.startExternalSync = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.startExternalSync(request), expectedError); + const actualRequest = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.startExternalSync as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes startExternalSync with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesStartExternalSyncRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.startExternalSync(request), expectedError); + }); + }); + + describe('performDiskShrink', () => { + it('invokes performDiskShrink without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.performDiskShrink = stubSimpleCall(expectedResponse); + const [response] = await client.performDiskShrink(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes performDiskShrink without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.performDiskShrink = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.performDiskShrink( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes performDiskShrink with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.performDiskShrink = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.performDiskShrink(request), expectedError); + const actualRequest = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.performDiskShrink as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes performDiskShrink with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPerformDiskShrinkRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.performDiskShrink(request), expectedError); + }); + }); + + describe('getDiskShrinkConfig', () => { + it('invokes getDiskShrinkConfig without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse(), + ); + client.innerApiCalls.getDiskShrinkConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.getDiskShrinkConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiskShrinkConfig without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigResponse(), + ); + client.innerApiCalls.getDiskShrinkConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDiskShrinkConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetDiskShrinkConfigResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiskShrinkConfig with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDiskShrinkConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDiskShrinkConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDiskShrinkConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getDiskShrinkConfig with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetDiskShrinkConfigRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDiskShrinkConfig(request), expectedError); + }); + }); + + describe('resetReplicaSize', () => { + it('invokes resetReplicaSize without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.resetReplicaSize = stubSimpleCall(expectedResponse); + const [response] = await client.resetReplicaSize(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetReplicaSize without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.resetReplicaSize = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resetReplicaSize( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetReplicaSize with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resetReplicaSize = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resetReplicaSize(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resetReplicaSize as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes resetReplicaSize with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesResetReplicaSizeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resetReplicaSize(request), expectedError); + }); + }); + + describe('getLatestRecoveryTime', () => { + it('invokes getLatestRecoveryTime without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse(), + ); + client.innerApiCalls.getLatestRecoveryTime = + stubSimpleCall(expectedResponse); + const [response] = await client.getLatestRecoveryTime(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLatestRecoveryTime without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeResponse(), + ); + client.innerApiCalls.getLatestRecoveryTime = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLatestRecoveryTime( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesGetLatestRecoveryTimeResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLatestRecoveryTime with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getLatestRecoveryTime = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.getLatestRecoveryTime(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getLatestRecoveryTime as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getLatestRecoveryTime with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesGetLatestRecoveryTimeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.getLatestRecoveryTime(request), + expectedError, + ); + }); + }); + + describe('executeSql', () => { + it('invokes executeSql without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse(), + ); + client.innerApiCalls.executeSql = stubSimpleCall(expectedResponse); + const [response] = await client.executeSql(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlResponse(), + ); + client.innerApiCalls.executeSql = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.executeSql( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesExecuteSqlResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.executeSql = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.executeSql(request), expectedError); + const actualRequest = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.executeSql as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes executeSql with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesExecuteSqlRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.executeSql(request), expectedError); + }); + }); + + describe('acquireSsrsLease', () => { + it('invokes acquireSsrsLease without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse(), + ); + client.innerApiCalls.acquireSsrsLease = stubSimpleCall(expectedResponse); + const [response] = await client.acquireSsrsLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes acquireSsrsLease without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseResponse(), + ); + client.innerApiCalls.acquireSsrsLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acquireSsrsLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesAcquireSsrsLeaseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes acquireSsrsLease with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acquireSsrsLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.acquireSsrsLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acquireSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes acquireSsrsLease with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesAcquireSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.acquireSsrsLease(request), expectedError); + }); + }); + + describe('releaseSsrsLease', () => { + it('invokes releaseSsrsLease without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse(), + ); + client.innerApiCalls.releaseSsrsLease = stubSimpleCall(expectedResponse); + const [response] = await client.releaseSsrsLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes releaseSsrsLease without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseResponse(), + ); + client.innerApiCalls.releaseSsrsLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.releaseSsrsLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISqlInstancesReleaseSsrsLeaseResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes releaseSsrsLease with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.releaseSsrsLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.releaseSsrsLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.releaseSsrsLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes releaseSsrsLease with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesReleaseSsrsLeaseRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.releaseSsrsLease(request), expectedError); + }); + }); + + describe('preCheckMajorVersionUpgrade', () => { + it('invokes preCheckMajorVersionUpgrade without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.preCheckMajorVersionUpgrade = + stubSimpleCall(expectedResponse); + const [response] = await client.preCheckMajorVersionUpgrade(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preCheckMajorVersionUpgrade without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.preCheckMajorVersionUpgrade = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.preCheckMajorVersionUpgrade( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preCheckMajorVersionUpgrade with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.preCheckMajorVersionUpgrade = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.preCheckMajorVersionUpgrade(request), + expectedError, + ); + const actualRequest = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.preCheckMajorVersionUpgrade as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes preCheckMajorVersionUpgrade with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPreCheckMajorVersionUpgradeRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects( + client.preCheckMajorVersionUpgrade(request), + expectedError, + ); + }); + }); + + describe('pointInTimeRestore', () => { + it('invokes pointInTimeRestore without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.pointInTimeRestore = + stubSimpleCall(expectedResponse); + const [response] = await client.pointInTimeRestore(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pointInTimeRestore without error using callback', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.pointInTimeRestore = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pointInTimeRestore( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pointInTimeRestore with error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pointInTimeRestore = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.pointInTimeRestore(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pointInTimeRestore as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes pointInTimeRestore with closed client', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlInstancesPointInTimeRestoreRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.pointInTimeRestore(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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 sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqlinstancesserviceModule.v1beta4.SqlInstancesServiceClient({ + 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-sql/test/gapic_sql_operations_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_operations_service_v1.ts index 5903ce5f34ca..56b5f9690f63 100644 --- a/packages/google-cloud-sql/test/gapic_sql_operations_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_operations_service_v1.ts @@ -19,771 +19,961 @@ 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 sqloperationsserviceModule from '../src'; -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 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.SqlOperationsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); - 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 = sqloperationsserviceModule.v1.SqlOperationsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqloperationsserviceModule.v1.SqlOperationsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1.SqlOperationsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); + 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 = + sqloperationsserviceModule.v1.SqlOperationsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqloperationsserviceModule.v1.SqlOperationsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('has port', () => { - const port = sqloperationsserviceModule.v1.SqlOperationsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlOperationsServiceStub, undefined); - await client.initialize(); - assert(client.sqlOperationsServiceStub); + it('has port', () => { + const port = + sqloperationsserviceModule.v1.SqlOperationsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlOperationsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlOperationsServiceStub, undefined); + await client.initialize(); + assert(client.sqlOperationsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlOperationsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlOperationsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlOperationsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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('get', () => { - it('invokes get without error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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('get', () => { + it('invokes get without error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.OperationsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.OperationsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperationsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); + it('invokes get without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('cancel', () => { - it('invokes cancel without error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.cancel = stubSimpleCall(expectedResponse); - const [response] = await client.cancel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel without error using callback', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.cancel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancel( - 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.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel with error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancel(request), expectedError); - const actualRequest = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel with closed client', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.cancel(request), expectedError); + it('invokes get with closed client', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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('list', () => { + it('invokes list without error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.OperationsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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 list without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.OperationsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperationsListResponse | 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes list with closed client', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + + describe('cancel', () => { + it('invokes cancel without error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.cancel = stubSimpleCall(expectedResponse); + const [response] = await client.cancel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel 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 cancel without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.cancel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancel( + 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.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel 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 cancel with error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancel(request), expectedError); + const actualRequest = (client.innerApiCalls.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancel with closed client', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.cancel(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqloperationsserviceModule.v1.SqlOperationsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_operations_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_operations_service_v1beta4.ts index 5fca4c39fd70..28cc64f3a40a 100644 --- a/packages/google-cloud-sql/test/gapic_sql_operations_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_operations_service_v1beta4.ts @@ -19,801 +19,1002 @@ 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 sqloperationsserviceModule from '../src'; -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 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('v1beta4.SqlOperationsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); - 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 = sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient.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 = + sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient + .servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlOperationsServiceStub, undefined); - await client.initialize(); - assert(client.sqlOperationsServiceStub); - }); + it('has port', () => { + const port = + sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlOperationsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlOperationsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlOperationsServiceStub, undefined); + await client.initialize(); + assert(client.sqlOperationsServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlOperationsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlOperationsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsGetRequest', ['operation']); - request.operation = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); - }); - - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.OperationsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.OperationsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperationsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); - }); - - describe('cancel', () => { - it('invokes cancel without error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.cancel = stubSimpleCall(expectedResponse); - const [response] = await client.cancel(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel without error using callback', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.cancel = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancel( - 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.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel with error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&operation=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancel = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancel(request), expectedError); - const actualRequest = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancel as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancel with closed client', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', ['operation']); - request.operation = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.cancel(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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('get', () => { + it('invokes get without error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get 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 get with error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get 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 get with closed client', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsGetRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.OperationsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ - 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 list without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.OperationsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperationsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list 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 list with error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with closed client', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + + describe('cancel', () => { + it('invokes cancel without error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.cancel = stubSimpleCall(expectedResponse); + const [response] = await client.cancel(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancel without error using callback', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.cancel = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancel( + 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.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancel with error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&operation=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancel = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancel(request), expectedError); + const actualRequest = (client.innerApiCalls.cancel as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancel as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancel with closed client', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlOperationsCancelRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlOperationsCancelRequest', + ['operation'], + ); + request.operation = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.cancel(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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 sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqloperationsserviceModule.v1beta4.SqlOperationsServiceClient({ + 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-sql/test/gapic_sql_ssl_certs_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1.ts index d3e88a5978ca..07ac5d56e9e0 100644 --- a/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1.ts @@ -19,927 +19,1140 @@ 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 sqlsslcertsserviceModule from '../src'; -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 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.SqlSslCertsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); + 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 = sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlSslCertsServiceStub, undefined); - await client.initialize(); - assert(client.sqlSslCertsServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlSslCertsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlSslCertsServiceStub, undefined); + await client.initialize(); + assert(client.sqlSslCertsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlSslCertsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlSslCertsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlSslCertsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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 delete without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete without error using callback', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); + it('invokes delete with error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCert() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with closed client', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - it('invokes get without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCert() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISslCert|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('get', () => { + it('invokes get without error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCert(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get without error using callback', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCert(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISslCert | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); + it('invokes get with error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCertsInsertResponse() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with closed client', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); - it('invokes insert without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCertsInsertResponse() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISslCertsInsertResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCertsInsertResponse(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert without error using callback', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCertsInsertResponse(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISslCertsInsertResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); + it('invokes insert with error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCertsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with closed client', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); - it('invokes list without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.SslCertsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ISslCertsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('list', () => { + it('invokes list without error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCertsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.SslCertsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ISslCertsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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)); - }); + + it('invokes list with closed client', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ + 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); - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlsslcertsserviceModule.v1.SqlSslCertsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', '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('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + 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)); - }); - }); + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1beta4.ts index 40109a1edb60..7b9549c8daf5 100644 --- a/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_ssl_certs_service_v1beta4.ts @@ -19,957 +19,1213 @@ 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 sqlsslcertsserviceModule from '../src'; -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 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('v1beta4.SqlSslCertsServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); - 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 = sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + it('has universeDomain', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); + 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 = + sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('has port', () => { - const port = sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.port; - assert(port); - assert(typeof port === 'number'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('should create a client with no option', () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - fallback: true, + 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + universeDomain: 'configured.example.com', }); - assert(client); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlSslCertsServiceStub, undefined); - await client.initialize(); - assert(client.sqlSslCertsServiceStub); + it('has port', () => { + const port = + sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlSslCertsServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlSslCertsServiceStub, undefined); + await client.initialize(); + assert(client.sqlSslCertsServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlSslCertsServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlSslCertsServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.sqlSslCertsServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes delete with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); - }); - - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCert() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCert() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISslCert|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&sha1_fingerprint=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes get with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', ['sha1Fingerprint']); - request.sha1Fingerprint = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); - }); - - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCertsInsertResponse() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCertsInsertResponse() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes insert with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); - }); - - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCertsListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list without error using callback', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SslCertsListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ISslCertsListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes list with closed client', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlSslCertsListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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('delete', () => { + it('invokes delete without error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes delete without error using callback', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete 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 delete with closed client', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsDeleteRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ - 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('get', () => { + it('invokes get without error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCert(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get 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 get without error using callback', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCert(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISslCert | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&sha1_fingerprint=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes get with closed client', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsGetRequest', + ['sha1Fingerprint'], + ); + request.sha1Fingerprint = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); + + describe('insert', () => { + it('invokes insert without error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCertsInsertResponse(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert without error using callback', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCertsInsertResponse(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISslCertsInsertResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes insert with closed client', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); + + describe('list', () => { + it('invokes list without error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCertsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list without error using callback', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SslCertsListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ISslCertsListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes list with closed client', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlSslCertsListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlSslCertsListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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 sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new sqlsslcertsserviceModule.v1beta4.SqlSslCertsServiceClient({ + 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-sql/test/gapic_sql_tiers_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1.ts index 7be02eaff388..0f48bbe07820 100644 --- a/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1.ts @@ -19,531 +19,635 @@ 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 sqltiersserviceModule from '../src'; -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 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.SqlTiersServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); + 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 = sqltiersserviceModule.v1.SqlTiersServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqltiersserviceModule.v1.SqlTiersServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqltiersserviceModule.v1.SqlTiersServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqltiersserviceModule.v1.SqlTiersServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqltiersserviceModule.v1.SqlTiersServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqltiersserviceModule.v1.SqlTiersServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqltiersserviceModule.v1.SqlTiersServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqltiersserviceModule.v1.SqlTiersServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqltiersserviceModule.v1.SqlTiersServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqltiersserviceModule.v1.SqlTiersServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqltiersserviceModule.v1.SqlTiersServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlTiersServiceStub, undefined); - await client.initialize(); - assert(client.sqlTiersServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlTiersServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlTiersServiceStub, undefined); + await client.initialize(); + assert(client.sqlTiersServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlTiersServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlTiersServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlTiersServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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('list', () => { - it('invokes list without error', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.TiersListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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('list', () => { + it('invokes list without error', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.TiersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list without error using callback', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.TiersListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.ITiersListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.TiersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.ITiersListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with error', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with closed client', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ - 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", "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('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getLocation with error', async () => { + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqltiersserviceModule.v1.SqlTiersServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1beta4.ts index 84dcb4615d7f..7eed7f7ae61f 100644 --- a/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_tiers_service_v1beta4.ts @@ -19,531 +19,637 @@ 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 sqltiersserviceModule from '../src'; -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 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('v1beta4.SqlTiersServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); + 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 = sqltiersserviceModule.v1beta4.SqlTiersServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqltiersserviceModule.v1beta4.SqlTiersServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqltiersserviceModule.v1beta4.SqlTiersServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqltiersserviceModule.v1beta4.SqlTiersServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqltiersserviceModule.v1beta4.SqlTiersServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqltiersserviceModule.v1beta4.SqlTiersServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlTiersServiceStub, undefined); - await client.initialize(); - assert(client.sqlTiersServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlTiersServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlTiersServiceStub, undefined); + await client.initialize(); + assert(client.sqlTiersServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlTiersServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlTiersServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlTiersServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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('list', () => { - it('invokes list without error', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.TiersListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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('list', () => { + it('invokes list without error', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.TiersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list without error using callback', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.TiersListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.ITiersListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.TiersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.ITiersListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with error', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlTiersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlTiersListRequest', ['project']); - request.project = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with closed client', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlTiersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlTiersListRequest', + ['project'], + ); + request.project = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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('Path templates', () => { - - describe('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ - 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", "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('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes getLocation with error', async () => { + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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 sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqltiersserviceModule.v1beta4.SqlTiersServiceClient({ + 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', '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('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_users_service_v1.ts b/packages/google-cloud-sql/test/gapic_sql_users_service_v1.ts index b5b898848b1b..ffbc06c9fd47 100644 --- a/packages/google-cloud-sql/test/gapic_sql_users_service_v1.ts +++ b/packages/google-cloud-sql/test/gapic_sql_users_service_v1.ts @@ -19,1035 +19,1267 @@ 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 sqlusersserviceModule from '../src'; -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 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.SqlUsersServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.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 = sqlusersserviceModule.v1.SqlUsersServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + it('has universeDomain', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlusersserviceModule.v1.SqlUsersServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlusersserviceModule.v1.SqlUsersServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlusersserviceModule.v1.SqlUsersServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlusersserviceModule.v1.SqlUsersServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.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 sqlusersserviceModule.v1.SqlUsersServiceClient({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 sqlusersserviceModule.v1.SqlUsersServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = sqlusersserviceModule.v1.SqlUsersServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.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 no option', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlusersserviceModule.v1.SqlUsersServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = sqlusersserviceModule.v1.SqlUsersServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlUsersServiceStub, undefined); - await client.initialize(); - assert(client.sqlUsersServiceStub); - }); + it('should create a client with no option', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlUsersServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlUsersServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlUsersServiceStub, undefined); + await client.initialize(); + assert(client.sqlUsersServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlUsersServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlUsersServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 delete without error using callback', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 delete with error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); + it('invokes delete without error using callback', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.User() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get without error using callback', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.User() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IUser|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with closed client', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - it('invokes get with error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('get', () => { + it('invokes get without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.User(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); + it('invokes get without error using callback', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.User(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IUser | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert without error using callback', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with closed client', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); - it('invokes insert with error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); + it('invokes insert without error using callback', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.UsersListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list without error using callback', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.UsersListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IUsersListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with closed client', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); - it('invokes list with error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('list', () => { + it('invokes list without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.UsersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list without error using callback', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.UsersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IUsersListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update without error using callback', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with closed client', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); - it('invokes update with error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('update', () => { + it('invokes update without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with closed client', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); - }); + it('invokes update without error using callback', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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)); - }); + + it('invokes update with error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes update with closed client', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ - 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); + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlusersserviceModule.v1.SqlUsersServiceClient({ + 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', '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('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + 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)); - }); - }); + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/test/gapic_sql_users_service_v1beta4.ts b/packages/google-cloud-sql/test/gapic_sql_users_service_v1beta4.ts index 46449019b106..10439be8e2e5 100644 --- a/packages/google-cloud-sql/test/gapic_sql_users_service_v1beta4.ts +++ b/packages/google-cloud-sql/test/gapic_sql_users_service_v1beta4.ts @@ -19,1035 +19,1269 @@ 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 sqlusersserviceModule from '../src'; -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 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('v1beta4.SqlUsersServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); + 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 = sqlusersserviceModule.v1beta4.SqlUsersServiceClient.servicePath; - assert.strictEqual(servicePath, 'sqladmin.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 = + sqlusersserviceModule.v1beta4.SqlUsersServiceClient.servicePath; + assert.strictEqual(servicePath, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = sqlusersserviceModule.v1beta4.SqlUsersServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + sqlusersserviceModule.v1beta4.SqlUsersServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'sqladmin.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'sqladmin.configured.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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + universeDomain: 'configured.example.com', }); - } - it('does not allow setting both universeDomain and universe_domain', () => { - assert.throws(() => { new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'sqladmin.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has port', () => { - const port = sqlusersserviceModule.v1beta4.SqlUsersServiceClient.port; - assert(port); - assert(typeof port === 'number'); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with no option', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); - assert(client); - }); + it('has port', () => { + const port = sqlusersserviceModule.v1beta4.SqlUsersServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('should create a client with gRPC fallback', () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - fallback: true, - }); - assert(client); - }); + it('should create a client with no option', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient(); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlUsersServiceStub, undefined); - await client.initialize(); - assert(client.sqlUsersServiceStub); - }); + it('should create a client with gRPC fallback', () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.sqlUsersServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlUsersServiceStub, undefined); + await client.initialize(); + assert(client.sqlUsersServiceStub); + }); - it('has close method for the non-initialized client', done => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.sqlUsersServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.sqlUsersServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.sqlUsersServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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('delete', () => { - it('invokes delete without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCall(expectedResponse); - const [response] = await client.delete(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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 delete without error using callback', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.delete = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.delete( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('delete', () => { + it('invokes delete without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = stubSimpleCall(expectedResponse); + const [response] = await client.delete(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.delete(request), expectedError); - const actualRequest = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.delete as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete without error using callback', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.delete = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.delete( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes delete with closed client', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.delete(request), expectedError); - }); + it('invokes delete with error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.delete = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.delete(request), expectedError); + const actualRequest = (client.innerApiCalls.delete as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.delete as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('get', () => { - it('invokes get without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.User() - ); - client.innerApiCalls.get = stubSimpleCall(expectedResponse); - const [response] = await client.get(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes delete with closed client', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersDeleteRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersDeleteRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.delete(request), expectedError); + }); + }); - it('invokes get without error using callback', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.User() - ); - client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.get( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IUser|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('get', () => { + it('invokes get without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.User(), + ); + client.innerApiCalls.get = stubSimpleCall(expectedResponse); + const [response] = await client.get(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }&name=${defaultValue3 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.get(request), expectedError); - const actualRequest = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.get as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get without error using callback', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.User(), + ); + client.innerApiCalls.get = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.get( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IUser | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes get with closed client', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['instance']); - request.instance = defaultValue2; - const defaultValue3 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersGetRequest', ['name']); - request.name = defaultValue3; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.get(request), expectedError); - }); + it('invokes get with error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}&name=${defaultValue3 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.get = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.get(request), expectedError); + const actualRequest = (client.innerApiCalls.get as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.get as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('insert', () => { - it('invokes insert without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCall(expectedResponse); - const [response] = await client.insert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes get with closed client', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersGetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['instance'], + ); + request.instance = defaultValue2; + const defaultValue3 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersGetRequest', + ['name'], + ); + request.name = defaultValue3; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.get(request), expectedError); + }); + }); - it('invokes insert without error using callback', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.insert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.insert( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('insert', () => { + it('invokes insert without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = stubSimpleCall(expectedResponse); + const [response] = await client.insert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.insert(request), expectedError); - const actualRequest = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.insert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert without error using callback', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.insert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.insert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes insert with closed client', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersInsertRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.insert(request), expectedError); - }); + it('invokes insert with error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.insert = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.insert(request), expectedError); + const actualRequest = (client.innerApiCalls.insert as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.insert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('list', () => { - it('invokes list without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UsersListResponse() - ); - client.innerApiCalls.list = stubSimpleCall(expectedResponse); - const [response] = await client.list(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes insert with closed client', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersInsertRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersInsertRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.insert(request), expectedError); + }); + }); - it('invokes list without error using callback', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.UsersListResponse() - ); - client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.list( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IUsersListResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('list', () => { + it('invokes list without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UsersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCall(expectedResponse); + const [response] = await client.list(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.list(request), expectedError); - const actualRequest = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.list as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list without error using callback', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.UsersListResponse(), + ); + client.innerApiCalls.list = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.list( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IUsersListResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes list with closed client', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersListRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersListRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.list(request), expectedError); - }); + it('invokes list with error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.list = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.list(request), expectedError); + const actualRequest = (client.innerApiCalls.list as SinonStub).getCall(0) + .args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.list as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('update', () => { - it('invokes update without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCall(expectedResponse); - const [response] = await client.update(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes list with closed client', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersListRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersListRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.list(request), expectedError); + }); + }); - it('invokes update without error using callback', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.Operation() - ); - client.innerApiCalls.update = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.update( - request, - (err?: Error|null, result?: protos.google.cloud.sql.v1beta4.IOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('update', () => { + it('invokes update without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = stubSimpleCall(expectedResponse); + const [response] = await client.update(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedHeaderRequestParams = `project=${defaultValue1 ?? '' }&instance=${defaultValue2 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.update(request), expectedError); - const actualRequest = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.update as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes update without error using callback', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.Operation(), + ); + client.innerApiCalls.update = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.update( + request, + ( + err?: Error | null, + result?: protos.google.cloud.sql.v1beta4.IOperation | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes update with closed client', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['project']); - request.project = defaultValue1; - const defaultValue2 = - getTypeDefaultValue('.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', ['instance']); - request.instance = defaultValue2; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.update(request), expectedError); - }); + it('invokes update with error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedHeaderRequestParams = `project=${defaultValue1 ?? ''}&instance=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.update = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.update(request), expectedError); + const actualRequest = (client.innerApiCalls.update as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.update as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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)); - }); + + it('invokes update with closed client', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.sql.v1beta4.SqlUsersUpdateRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['project'], + ); + request.project = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.cloud.sql.v1beta4.SqlUsersUpdateRequest', + ['instance'], + ); + request.instance = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.update(request), expectedError); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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!); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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 sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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('backup', async () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - backup: "backupValue", - }; - const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ - 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); + describe('Path templates', () => { + describe('backup', async () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + backup: 'backupValue', + }; + const client = new sqlusersserviceModule.v1beta4.SqlUsersServiceClient({ + 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", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('backupPath', () => { + const result = client.backupPath('projectValue', '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('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + 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)); - }); - }); + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-sql/webpack.config.js b/packages/google-cloud-sql/webpack.config.js index 6968d355a69c..07dc78031d41 100644 --- a/packages/google-cloud-sql/webpack.config.js +++ b/packages/google-cloud-sql/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-storagebatchoperations/.eslintignore b/packages/google-cloud-storagebatchoperations/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-storagebatchoperations/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-storagebatchoperations/.eslintrc.json b/packages/google-cloud-storagebatchoperations/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-storagebatchoperations/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-storagebatchoperations/README.md b/packages/google-cloud-storagebatchoperations/README.md index bc56ad39685d..e9deecdd573a 100644 --- a/packages/google-cloud-storagebatchoperations/README.md +++ b/packages/google-cloud-storagebatchoperations/README.md @@ -98,7 +98,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-storagebatchoperations/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`) @@ -108,7 +108,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-storagebatchoperations/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-storagebatchoperations/protos/protos.d.ts b/packages/google-cloud-storagebatchoperations/protos/protos.d.ts index 4a5b6bc797dc..18f28d7c2cf5 100644 --- a/packages/google-cloud-storagebatchoperations/protos/protos.d.ts +++ b/packages/google-cloud-storagebatchoperations/protos/protos.d.ts @@ -3917,6 +3917,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -3934,6 +3937,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 @@ -4634,6 +4640,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -4648,6 +4657,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 @@ -4726,6 +4738,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 { @@ -5052,6 +5176,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -5066,6 +5193,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 @@ -5390,6 +5520,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, @@ -5420,6 +5653,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. */ @@ -5434,6 +5670,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 @@ -5524,6 +5763,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 { @@ -5880,6 +6216,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -5910,6 +6247,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -5959,6 +6299,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -6093,6 +6436,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -6134,6 +6480,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 @@ -6981,6 +7330,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -7007,6 +7359,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 @@ -7941,6 +8296,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); @@ -7999,6 +8357,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[]; @@ -8219,6 +8580,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. */ @@ -8457,6 +8933,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -8479,6 +8958,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[]; @@ -9071,6 +9553,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. */ @@ -9100,6 +9588,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 @@ -9222,6 +9716,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. */ @@ -9341,8 +9945,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. */ @@ -9357,8 +9964,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. @@ -9891,6 +10501,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-storagebatchoperations/protos/protos.js b/packages/google-cloud-storagebatchoperations/protos/protos.js index 155072cf31f3..a3afec06dccc 100644 --- a/packages/google-cloud-storagebatchoperations/protos/protos.js +++ b/packages/google-cloud-storagebatchoperations/protos/protos.js @@ -10338,6 +10338,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -10372,6 +10373,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 @@ -10404,6 +10413,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; }; @@ -10455,6 +10466,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; @@ -10506,6 +10521,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; }; @@ -10548,6 +10568,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; }; @@ -10566,8 +10591,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) { @@ -10575,6 +10602,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; }; @@ -12397,6 +12426,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -12422,6 +12452,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 @@ -12448,6 +12486,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; }; @@ -12488,6 +12528,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; @@ -12528,6 +12572,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; }; @@ -12548,6 +12597,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; }; @@ -12564,10 +12618,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; }; @@ -12597,6 +12655,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; })(); @@ -13473,6 +13783,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -13484,6 +13795,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) @@ -13498,6 +13810,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 @@ -13524,6 +13844,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; }; @@ -13554,7 +13877,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) @@ -13564,6 +13887,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; @@ -13604,6 +13950,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; }; @@ -13624,6 +13978,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; }; @@ -13640,10 +14001,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; }; @@ -14282,30 +14651,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; })(); /** @@ -14343,6 +14957,7 @@ * @memberof google.api * @interface IFieldInfo * @property {google.api.FieldInfo.Format|null} [format] FieldInfo format + * @property {Array.|null} [referencedTypes] FieldInfo referencedTypes */ /** @@ -14354,6 +14969,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) @@ -14368,6 +14984,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 @@ -14394,6 +15018,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; }; @@ -14434,6 +15061,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; @@ -14480,6 +15113,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; }; @@ -14523,6 +15165,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; }; @@ -14539,10 +15191,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; }; @@ -14595,32 +15254,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) @@ -14628,50 +15279,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 = ""; @@ -15526,6 +16390,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 @@ -15540,6 +16405,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; @@ -15564,6 +16430,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 @@ -15586,6 +16453,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -15636,6 +16504,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 @@ -15757,6 +16633,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; }; @@ -15829,6 +16708,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 = []; @@ -15931,6 +16816,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"; @@ -15985,6 +16877,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -16037,6 +16930,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"); @@ -16100,6 +17000,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -16165,6 +17069,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -16221,6 +17126,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; }; @@ -16269,6 +17179,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 */ /** @@ -16374,6 +17285,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 @@ -16426,6 +17345,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; }; @@ -16518,6 +17439,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -16631,6 +17556,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; }; @@ -16730,6 +17664,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; }; @@ -16759,6 +17713,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; @@ -16804,6 +17759,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; }; @@ -18848,6 +19805,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 */ /** @@ -18908,6 +19866,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 @@ -18945,6 +19911,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; }; @@ -19007,6 +19975,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -19075,6 +20047,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; }; @@ -19124,6 +20105,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; }; @@ -19148,6 +20149,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; @@ -19168,6 +20170,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; }; @@ -21486,6 +22490,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 @@ -21607,6 +22612,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 @@ -21689,6 +22702,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(); @@ -21792,6 +22807,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 = []; @@ -21931,6 +22950,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"; @@ -22124,6 +23148,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"); @@ -22226,6 +23255,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; } @@ -22259,6 +23289,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) @@ -22533,6 +23565,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -22574,103 +23607,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; @@ -23265,6 +24784,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 */ @@ -23308,6 +24828,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 @@ -23346,6 +24874,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(); @@ -23397,6 +24927,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 = []; @@ -23449,6 +24983,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"; @@ -23482,6 +25021,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"); @@ -23514,6 +25058,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -23521,6 +25066,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) @@ -24988,6 +26535,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 */ /** @@ -25053,6 +26602,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 @@ -25089,6 +26654,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; }; @@ -25149,6 +26718,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; @@ -25239,6 +26816,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; }; @@ -25378,6 +26975,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; }; @@ -25401,6 +27046,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; @@ -25414,6 +27061,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; }; @@ -25541,6 +27192,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; })(); @@ -25725,6 +27589,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -25742,6 +27607,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -25790,6 +27656,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -25842,6 +27712,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -25950,7 +27824,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 */ /** @@ -25977,12 +27852,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. @@ -26008,10 +27891,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; }; @@ -26052,8 +27937,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: @@ -26096,6 +27985,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -26108,10 +27998,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; }; @@ -26139,6 +28034,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -26180,10 +28079,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; }; @@ -26202,13 +28106,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; }; @@ -27423,6 +29330,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-storagebatchoperations/protos/protos.json b/packages/google-cloud-storagebatchoperations/protos/protos.json index 00ce8bf37e47..5453a3ed0651 100644 --- a/packages/google-cloud-storagebatchoperations/protos/protos.json +++ b/packages/google-cloud-storagebatchoperations/protos/protos.json @@ -1193,8 +1193,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": { @@ -1318,6 +1317,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1458,6 +1461,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 + } + } } } }, @@ -1515,6 +1540,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1576,6 +1606,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1620,6 +1663,11 @@ "format": { "type": "Format", "id": 1 + }, + "referencedTypes": { + "rule": "repeated", + "type": "TypeReference", + "id": 2 } }, "nested": { @@ -1634,6 +1682,14 @@ } } }, + "TypeReference": { + "fields": { + "typeName": { + "type": "string", + "id": 1 + } + } + }, "resourceReference": { "type": "google.api.ResourceReference", "id": 1055, @@ -1732,12 +1788,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, @@ -1776,6 +1839,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -1864,6 +1932,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2089,6 +2161,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2139,7 +2215,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2303,6 +2386,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2438,7 +2522,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2466,6 +2551,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2535,6 +2624,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 + } + } } } }, @@ -2623,6 +2732,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2765,6 +2878,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2775,6 +2889,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2785,6 +2900,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -2795,6 +2911,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -2805,7 +2922,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" } }, @@ -2815,27 +2933,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, @@ -2880,7 +3009,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -2895,6 +3030,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 + } + } + } } } }, @@ -2922,11 +3084,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -2939,6 +3116,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3024,6 +3207,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3123,6 +3314,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-storagebatchoperations/samples/generated/v1/snippet_metadata_google.cloud.storagebatchoperations.v1.json b/packages/google-cloud-storagebatchoperations/samples/generated/v1/snippet_metadata_google.cloud.storagebatchoperations.v1.json index fbee03893bec..fdf71d7cee04 100644 --- a/packages/google-cloud-storagebatchoperations/samples/generated/v1/snippet_metadata_google.cloud.storagebatchoperations.v1.json +++ b/packages/google-cloud-storagebatchoperations/samples/generated/v1/snippet_metadata_google.cloud.storagebatchoperations.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-storagebatchoperations", - "version": "0.3.0", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-storagebatchoperations/src/v1/index.ts b/packages/google-cloud-storagebatchoperations/src/v1/index.ts index 8c340f64ce4b..5614cf942a28 100644 --- a/packages/google-cloud-storagebatchoperations/src/v1/index.ts +++ b/packages/google-cloud-storagebatchoperations/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {StorageBatchOperationsClient} from './storage_batch_operations_client'; +export { StorageBatchOperationsClient } from './storage_batch_operations_client'; diff --git a/packages/google-cloud-storagebatchoperations/src/v1/storage_batch_operations_client.ts b/packages/google-cloud-storagebatchoperations/src/v1/storage_batch_operations_client.ts index e22956e87a2c..8e73d0aa080c 100644 --- a/packages/google-cloud-storagebatchoperations/src/v1/storage_batch_operations_client.ts +++ b/packages/google-cloud-storagebatchoperations/src/v1/storage_batch_operations_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 @@ -47,7 +58,7 @@ export class StorageBatchOperationsClient { 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('storagebatchoperations'); @@ -60,11 +71,11 @@ export class StorageBatchOperationsClient { 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; - storageBatchOperationsStub?: Promise<{[name: string]: Function}>; + storageBatchOperationsStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of StorageBatchOperationsClient. @@ -105,21 +116,43 @@ export class StorageBatchOperationsClient { * const client = new StorageBatchOperationsClient({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 StorageBatchOperationsClient; - 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 StorageBatchOperationsClient; + 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 = 'storagebatchoperations.' + 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 +177,7 @@ export class StorageBatchOperationsClient { 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; @@ -158,15 +191,11 @@ export class StorageBatchOperationsClient { } 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,16 +217,16 @@ export class StorageBatchOperationsClient { // Create useful helper objects for these. this.pathTemplates = { bucketOperationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}/bucketOperations/{bucket_operation}' + 'projects/{project}/locations/{location}/jobs/{job}/bucketOperations/{bucket_operation}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/jobs/{job}' + 'projects/{project}/locations/{location}/jobs/{job}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), }; @@ -205,10 +234,16 @@ export class StorageBatchOperationsClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs'), - listBucketOperations: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'bucketOperations') + listJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'jobs', + ), + listBucketOperations: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'bucketOperations', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -217,29 +252,63 @@ export class StorageBatchOperationsClient { // 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 createJobResponse = protoFilesRoot.lookup( - '.google.cloud.storagebatchoperations.v1.Job') as gax.protobuf.Type; + '.google.cloud.storagebatchoperations.v1.Job', + ) as gax.protobuf.Type; const createJobMetadata = protoFilesRoot.lookup( - '.google.cloud.storagebatchoperations.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storagebatchoperations.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createJob: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createJobResponse.decode.bind(createJobResponse), - createJobMetadata.decode.bind(createJobMetadata)) + createJobMetadata.decode.bind(createJobMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.storagebatchoperations.v1.StorageBatchOperations', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.storagebatchoperations.v1.StorageBatchOperations', + 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 @@ -270,28 +339,42 @@ export class StorageBatchOperationsClient { // Put together the "service stub" for // google.cloud.storagebatchoperations.v1.StorageBatchOperations. this.storageBatchOperationsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.storagebatchoperations.v1.StorageBatchOperations') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.storagebatchoperations.v1.StorageBatchOperations, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.storagebatchoperations.v1.StorageBatchOperations', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.storagebatchoperations.v1 + .StorageBatchOperations, + 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 storageBatchOperationsStubMethods = - ['listJobs', 'getJob', 'createJob', 'deleteJob', 'cancelJob', 'listBucketOperations', 'getBucketOperation']; + const storageBatchOperationsStubMethods = [ + 'listJobs', + 'getJob', + 'createJob', + 'deleteJob', + 'cancelJob', + 'listBucketOperations', + 'getBucketOperation', + ]; for (const methodName of storageBatchOperationsStubMethods) { const callPromise = this.storageBatchOperationsStub.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] || @@ -301,7 +384,7 @@ export class StorageBatchOperationsClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -316,8 +399,14 @@ export class StorageBatchOperationsClient { * @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 'storagebatchoperations.googleapis.com'; } @@ -328,8 +417,14 @@ export class StorageBatchOperationsClient { * @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 'storagebatchoperations.googleapis.com'; } @@ -360,9 +455,7 @@ export class StorageBatchOperationsClient { * @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; @@ -371,8 +464,9 @@ export class StorageBatchOperationsClient { * 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; @@ -383,610 +477,887 @@ export class StorageBatchOperationsClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets a batch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. `name` of the job to retrieve. - * Format: projects/{project_id}/locations/global/jobs/{job_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.storagebatchoperations.v1.Job|Job}. - * Please see the {@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/storage_batch_operations.get_job.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_GetJob_async - */ + /** + * Gets a batch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. `name` of the job to retrieve. + * Format: projects/{project_id}/locations/global/jobs/{job_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.storagebatchoperations.v1.Job|Job}. + * Please see the {@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/storage_batch_operations.get_job.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_GetJob_async + */ getJob( - request?: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IGetJobRequest | undefined, + {} | undefined, + ] + >; getJob( - request: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.IJob, + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getJob( - request: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.IJob, + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getJob( - request?: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storagebatchoperations.v1.IGetJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storagebatchoperations.v1.IJob, + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IGetJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storagebatchoperations.v1.IJob, + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storagebatchoperations.v1.IJob, - protos.google.cloud.storagebatchoperations.v1.IGetJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('getJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storagebatchoperations.v1.IJob, + ( + | protos.google.cloud.storagebatchoperations.v1.IGetJobRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 batch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The `name` of the job to delete. - * Format: projects/{project_id}/locations/global/jobs/{job_id} . - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID in case you need to retry your request. Requests with same - * `request_id` will be ignored for at least 60 minutes since the first - * request. 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 bucket operations of the job will also - * be deleted. Highly recommended to be set to true by all clients. Users - * cannot mutate bucket operations directly, so only the jobs.delete - * permission is required to delete a job (and its child bucket operations). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/storage_batch_operations.delete_job.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_DeleteJob_async - */ + /** + * Deletes a batch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The `name` of the job to delete. + * Format: projects/{project_id}/locations/global/jobs/{job_id} . + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID in case you need to retry your request. Requests with same + * `request_id` will be ignored for at least 60 minutes since the first + * request. 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 bucket operations of the job will also + * be deleted. Highly recommended to be set to true by all clients. Users + * cannot mutate bucket operations directly, so only the jobs.delete + * permission is required to delete a job (and its child bucket operations). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/storage_batch_operations.delete_job.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_DeleteJob_async + */ deleteJob( - request?: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | undefined + ), + {} | undefined, + ] + >; deleteJob( - request: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request?: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteJob request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storagebatchoperations.v1.IDeleteJobRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Cancels a batch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The `name` of the job to cancel. - * Format: projects/{project_id}/locations/global/jobs/{job_id}. - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID in case you need to retry your request. Requests with same - * `request_id` will be ignored for at least 60 minutes since the first - * request. 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.storagebatchoperations.v1.CancelJobResponse|CancelJobResponse}. - * Please see the {@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/storage_batch_operations.cancel_job.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CancelJob_async - */ + /** + * Cancels a batch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The `name` of the job to cancel. + * Format: projects/{project_id}/locations/global/jobs/{job_id}. + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID in case you need to retry your request. Requests with same + * `request_id` will be ignored for at least 60 minutes since the first + * request. 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.storagebatchoperations.v1.CancelJobResponse|CancelJobResponse}. + * Please see the {@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/storage_batch_operations.cancel_job.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CancelJob_async + */ cancelJob( - request?: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + ( + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | undefined + ), + {} | undefined, + ] + >; cancelJob( - request: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; cancelJob( - request: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | null + | undefined, + {} | null | undefined + >, + ): void; cancelJob( - request?: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + ( + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('cancelJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('cancelJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.cancelJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, - protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('cancelJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .cancelJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse, + ( + | protos.google.cloud.storagebatchoperations.v1.ICancelJobRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('cancelJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a BucketOperation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. `name` of the bucket operation to retrieve. - * Format: - * projects/{project_id}/locations/global/jobs/{job_id}/bucketOperations/{bucket_operation_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.storagebatchoperations.v1.BucketOperation|BucketOperation}. - * Please see the {@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/storage_batch_operations.get_bucket_operation.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_GetBucketOperation_async - */ + /** + * Gets a BucketOperation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. `name` of the bucket operation to retrieve. + * Format: + * projects/{project_id}/locations/global/jobs/{job_id}/bucketOperations/{bucket_operation_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.storagebatchoperations.v1.BucketOperation|BucketOperation}. + * Please see the {@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/storage_batch_operations.get_bucket_operation.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_GetBucketOperation_async + */ getBucketOperation( - request?: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + ( + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | undefined + ), + {} | undefined, + ] + >; getBucketOperation( - request: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBucketOperation( - request: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, - callback: Callback< - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, + callback: Callback< + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getBucketOperation( - request?: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + ( + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getBucketOperation request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getBucketOperation response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getBucketOperation(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation, - protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest|undefined, - {}|undefined - ]) => { - this._log.info('getBucketOperation response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getBucketOperation(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation, + ( + | protos.google.cloud.storagebatchoperations.v1.IGetBucketOperationRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getBucketOperation response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 batch job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.jobId - * Required. The optional `job_id` for this Job . If not - * specified, an id is generated. `job_id` should be no more than 128 - * characters and must include only characters available in DNS names, as - * defined by RFC-1123. - * @param {google.cloud.storagebatchoperations.v1.Job} request.job - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. An optional request ID to identify requests. Specify a unique - * request ID in case you need to retry your request. Requests with same - * `request_id` will be ignored for at least 60 minutes since the first - * request. 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/storage_batch_operations.create_job.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CreateJob_async - */ + /** + * Creates a batch job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.jobId + * Required. The optional `job_id` for this Job . If not + * specified, an id is generated. `job_id` should be no more than 128 + * characters and must include only characters available in DNS names, as + * defined by RFC-1123. + * @param {google.cloud.storagebatchoperations.v1.Job} request.job + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. An optional request ID to identify requests. Specify a unique + * request ID in case you need to retry your request. Requests with same + * `request_id` will be ignored for at least 60 minutes since the first + * request. 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/storage_batch_operations.create_job.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CreateJob_async + */ createJob( - request?: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createJob( - request: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, + callback: Callback< + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request?: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storagebatchoperations.v1.ICreateJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.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.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createJob response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createJob request %j', request); - return this.innerApiCalls.createJob(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createJob response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createJob(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createJob response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createJob()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_batch_operations.create_job.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CreateJob_async - */ - async checkCreateJobProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createJob()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_batch_operations.create_job.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_CreateJob_async + */ + async checkCreateJobProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.storagebatchoperations.v1.Job, + protos.google.cloud.storagebatchoperations.v1.OperationMetadata + > + > { this._log.info('createJob long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createJob, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createJob, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.storagebatchoperations.v1.Job, + protos.google.cloud.storagebatchoperations.v1.OperationMetadata + >; } - /** - * Lists Jobs in a given project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: projects/{project_id}/locations/global. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 Jobs in a given project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: projects/{project_id}/locations/global. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobs( - request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IJob[], - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IJob[], + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListJobsResponse, + ] + >; listJobs( - request: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IJob>): void; + request: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListJobsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IJob + >, + ): void; listJobs( - request: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IJob>): void; + request: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListJobsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IJob + >, + ): void; listJobs( - request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IJob>, - callback?: PaginationCallback< + request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IJob>): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IJob[], - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.IListJobsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IJob + >, + callback?: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListJobsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IJob + >, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IJob[], + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListJobsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.storagebatchoperations.v1.IListJobsRequest, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IJob>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListJobsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IJob + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listJobs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -995,201 +1366,230 @@ export class StorageBatchOperationsClient { this._log.info('listJobs request %j', request); return this.innerApiCalls .listJobs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.storagebatchoperations.v1.IJob[], - protos.google.cloud.storagebatchoperations.v1.IListJobsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListJobsResponse - ]) => { - this._log.info('listJobs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.storagebatchoperations.v1.IJob[], + protos.google.cloud.storagebatchoperations.v1.IListJobsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListJobsResponse, + ]) => { + this._log.info('listJobs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listJobs`, 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/global. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 `listJobs`, 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/global. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobsStream( - request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs stream %j', request); return this.descriptors.page.listJobs.createStream( this.innerApiCalls.listJobs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listJobs`, 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/global. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job}. 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/storage_batch_operations.list_jobs.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_ListJobs_async - */ + /** + * Equivalent to `listJobs`, 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/global. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.Job|Job}. 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/storage_batch_operations.list_jobs.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_ListJobs_async + */ listJobsAsync( - request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.storagebatchoperations.v1.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs iterate %j', request); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists BucketOperations in a given project and job. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Format: projects/{project_id}/locations/global/jobs/{job_id}. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. Default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation}. - * 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 `listBucketOperationsAsync()` - * method described below for async iteration which you can stop as 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 BucketOperations in a given project and job. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Format: projects/{project_id}/locations/global/jobs/{job_id}. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. Default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation}. + * 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 `listBucketOperationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBucketOperations( - request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse - ]>; + request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse, + ] + >; listBucketOperations( - request: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IBucketOperation>): void; + request: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IBucketOperation + >, + ): void; listBucketOperations( - request: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - callback: PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IBucketOperation>): void; + request: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + callback: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IBucketOperation + >, + ): void; listBucketOperations( - request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IBucketOperation>, - callback?: PaginationCallback< + request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IBucketOperation>): - Promise<[ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse - ]>|void { + | protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IBucketOperation + >, + callback?: PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IBucketOperation + >, + ): Promise< + [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.storagebatchoperations.v1.IListBucketOperationsRequest, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse|null|undefined, - protos.google.cloud.storagebatchoperations.v1.IBucketOperation>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + | protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse + | null + | undefined, + protos.google.cloud.storagebatchoperations.v1.IBucketOperation + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listBucketOperations values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1198,117 +1598,122 @@ export class StorageBatchOperationsClient { this._log.info('listBucketOperations request %j', request); return this.innerApiCalls .listBucketOperations(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest|null, - protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse - ]) => { - this._log.info('listBucketOperations values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.storagebatchoperations.v1.IBucketOperation[], + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest | null, + protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsResponse, + ]) => { + this._log.info('listBucketOperations values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listBucketOperations`, 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/global/jobs/{job_id}. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. Default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation} 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 `listBucketOperationsAsync()` - * method described below for async iteration which you can stop as 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 `listBucketOperations`, 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/global/jobs/{job_id}. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. Default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation} 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 `listBucketOperationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listBucketOperationsStream( - request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + 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['listBucketOperations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBucketOperations stream %j', request); return this.descriptors.page.listBucketOperations.createStream( this.innerApiCalls.listBucketOperations as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listBucketOperations`, 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/global/jobs/{job_id}. - * @param {string} [request.filter] - * Optional. Filters results as defined by https://google.aip.dev/160. - * @param {number} [request.pageSize] - * Optional. The list page size. Default page size is 100. - * @param {string} [request.pageToken] - * Optional. The list page token. - * @param {string} [request.orderBy] - * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation}. 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/storage_batch_operations.list_bucket_operations.js - * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_ListBucketOperations_async - */ + /** + * Equivalent to `listBucketOperations`, 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/global/jobs/{job_id}. + * @param {string} [request.filter] + * Optional. Filters results as defined by https://google.aip.dev/160. + * @param {number} [request.pageSize] + * Optional. The list page size. Default page size is 100. + * @param {string} [request.pageToken] + * Optional. The list page token. + * @param {string} [request.orderBy] + * Optional. Field to sort by. Supported fields are 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.storagebatchoperations.v1.BucketOperation|BucketOperation}. 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/storage_batch_operations.list_bucket_operations.js + * region_tag:storagebatchoperations_v1_generated_StorageBatchOperations_ListBucketOperations_async + */ listBucketOperationsAsync( - request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.storagebatchoperations.v1.IListBucketOperationsRequest, + 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['listBucketOperations']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listBucketOperations iterate %j', request); return this.descriptors.page.listBucketOperations.asyncIterate( this.innerApiCalls['listBucketOperations'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -1343,12 +1748,11 @@ export class StorageBatchOperationsClient { | 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. @@ -1381,12 +1785,12 @@ export class StorageBatchOperationsClient { */ 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. @@ -1429,22 +1833,22 @@ export class StorageBatchOperationsClient { 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); } /** @@ -1479,15 +1883,15 @@ export class StorageBatchOperationsClient { */ 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); } /** @@ -1521,7 +1925,7 @@ export class StorageBatchOperationsClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -1534,25 +1938,24 @@ export class StorageBatchOperationsClient { 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 @@ -1591,22 +1994,22 @@ export class StorageBatchOperationsClient { 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); } @@ -1623,7 +2026,12 @@ export class StorageBatchOperationsClient { * @param {string} bucket_operation * @returns {string} Resource name string. */ - bucketOperationPath(project:string,location:string,job:string,bucketOperation:string) { + bucketOperationPath( + project: string, + location: string, + job: string, + bucketOperation: string, + ) { return this.pathTemplates.bucketOperationPathTemplate.render({ project: project, location: location, @@ -1640,7 +2048,9 @@ export class StorageBatchOperationsClient { * @returns {string} A string representing the project. */ matchProjectFromBucketOperationName(bucketOperationName: string) { - return this.pathTemplates.bucketOperationPathTemplate.match(bucketOperationName).project; + return this.pathTemplates.bucketOperationPathTemplate.match( + bucketOperationName, + ).project; } /** @@ -1651,7 +2061,9 @@ export class StorageBatchOperationsClient { * @returns {string} A string representing the location. */ matchLocationFromBucketOperationName(bucketOperationName: string) { - return this.pathTemplates.bucketOperationPathTemplate.match(bucketOperationName).location; + return this.pathTemplates.bucketOperationPathTemplate.match( + bucketOperationName, + ).location; } /** @@ -1662,7 +2074,9 @@ export class StorageBatchOperationsClient { * @returns {string} A string representing the job. */ matchJobFromBucketOperationName(bucketOperationName: string) { - return this.pathTemplates.bucketOperationPathTemplate.match(bucketOperationName).job; + return this.pathTemplates.bucketOperationPathTemplate.match( + bucketOperationName, + ).job; } /** @@ -1673,7 +2087,9 @@ export class StorageBatchOperationsClient { * @returns {string} A string representing the bucket_operation. */ matchBucketOperationFromBucketOperationName(bucketOperationName: string) { - return this.pathTemplates.bucketOperationPathTemplate.match(bucketOperationName).bucket_operation; + return this.pathTemplates.bucketOperationPathTemplate.match( + bucketOperationName, + ).bucket_operation; } /** @@ -1684,7 +2100,7 @@ export class StorageBatchOperationsClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,location:string,job:string) { + jobPath(project: string, location: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, location: location, @@ -1732,7 +2148,7 @@ export class StorageBatchOperationsClient { * @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, @@ -1767,7 +2183,7 @@ export class StorageBatchOperationsClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1792,14 +2208,16 @@ export class StorageBatchOperationsClient { */ close(): Promise { if (this.storageBatchOperationsStub && !this._terminated) { - return this.storageBatchOperationsStub.then(stub => { + return this.storageBatchOperationsStub.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-storagebatchoperations/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-storagebatchoperations/system-test/fixtures/sample/src/index.ts index 3320355ef6c8..e71992a2a37d 100644 --- a/packages/google-cloud-storagebatchoperations/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-storagebatchoperations/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,12 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {StorageBatchOperationsClient} from '@google-cloud/storagebatchoperations'; +import { StorageBatchOperationsClient } from '@google-cloud/storagebatchoperations'; // check that the client class type name can be used -function doStuffWithStorageBatchOperationsClient(client: StorageBatchOperationsClient) { +function doStuffWithStorageBatchOperationsClient( + client: StorageBatchOperationsClient, +) { client.close(); } diff --git a/packages/google-cloud-storagebatchoperations/system-test/install.ts b/packages/google-cloud-storagebatchoperations/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-storagebatchoperations/system-test/install.ts +++ b/packages/google-cloud-storagebatchoperations/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-storagebatchoperations/test/gapic_storage_batch_operations_v1.ts b/packages/google-cloud-storagebatchoperations/test/gapic_storage_batch_operations_v1.ts index 2c865f9f4055..c5f9a80785ba 100644 --- a/packages/google-cloud-storagebatchoperations/test/gapic_storage_batch_operations_v1.ts +++ b/packages/google-cloud-storagebatchoperations/test/gapic_storage_batch_operations_v1.ts @@ -19,1927 +19,2538 @@ 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 storagebatchoperationsModule 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.StorageBatchOperationsClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'storagebatchoperations.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); - 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 = storagebatchoperationsModule.v1.StorageBatchOperationsClient.servicePath; - assert.strictEqual(servicePath, 'storagebatchoperations.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'storagebatchoperations.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = storagebatchoperationsModule.v1.StorageBatchOperationsClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'storagebatchoperations.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storagebatchoperations.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storagebatchoperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storagebatchoperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storagebatchoperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = storagebatchoperationsModule.v1.StorageBatchOperationsClient.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 = + storagebatchoperationsModule.v1.StorageBatchOperationsClient + .servicePath; + assert.strictEqual( + servicePath, + 'storagebatchoperations.googleapis.com', + ); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + storagebatchoperationsModule.v1.StorageBatchOperationsClient + .apiEndpoint; + assert.strictEqual( + apiEndpoint, + 'storagebatchoperations.googleapis.com', + ); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storagebatchoperations.example.com'); + }); - it('should create a client with no option', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storagebatchoperations.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storagebatchoperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'storagebatchoperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.storageBatchOperationsStub, undefined); - await client.initialize(); - assert(client.storageBatchOperationsStub); - }); + it('has port', () => { + const port = + storagebatchoperationsModule.v1.StorageBatchOperationsClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.storageBatchOperationsStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('should create a client with no option', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + fallback: true, }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.storageBatchOperationsStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has initialize method and supports deferred initialization', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.storageBatchOperationsStub, undefined); + await client.initialize(); + assert(client.storageBatchOperationsStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.storageBatchOperationsStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.storageBatchOperationsStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.storagebatchoperations.v1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getJob with closed client', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getJob(request), expectedError); - }); - }); - - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes deleteJob with closed client', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteJob(request), expectedError); - }); - }); - - describe('cancelJob', () => { - it('invokes cancelJob without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CancelJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobResponse() - ); - client.innerApiCalls.cancelJob = stubSimpleCall(expectedResponse); - const [response] = await client.cancelJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelJob without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CancelJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobResponse() - ); - client.innerApiCalls.cancelJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelJob( - request, - (err?: Error|null, result?: protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelJob with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CancelJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelJob(request), expectedError); - const actualRequest = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes cancelJob with closed client', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CancelJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.cancelJob(request), expectedError); - }); - }); - - describe('getBucketOperation', () => { - it('invokes getBucketOperation without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.BucketOperation() - ); - client.innerApiCalls.getBucketOperation = stubSimpleCall(expectedResponse); - const [response] = await client.getBucketOperation(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBucketOperation without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.BucketOperation() - ); - client.innerApiCalls.getBucketOperation = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBucketOperation( - request, - (err?: Error|null, result?: protos.google.cloud.storagebatchoperations.v1.IBucketOperation|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBucketOperation with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getBucketOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBucketOperation(request), expectedError); - const actualRequest = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getBucketOperation as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getBucketOperation with closed client', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getBucketOperation(request), expectedError); - }); - }); - - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createJob = stubLongRunningCall(expectedResponse); - const [operation] = await client.createJob(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createJob = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with call error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createJob with LRO error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createJob(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes checkCreateJobProgress without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateJobProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateJobProgress with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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.checkCreateJobProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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('getJob', () => { + it('invokes getJob without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.storagebatchoperations.v1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobs with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listJobsStream without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storagebatchoperations.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.storagebatchoperations.v1.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listJobsStream with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storagebatchoperations.v1.Job[] = []; - stream.on('data', (response: protos.google.cloud.storagebatchoperations.v1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.storagebatchoperations.v1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes getJob without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ); + client.innerApiCalls.getJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storagebatchoperations.v1.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listJobs with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.storagebatchoperations.v1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('listBucketOperations', () => { - it('invokes listBucketOperations without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - ]; - client.innerApiCalls.listBucketOperations = stubSimpleCall(expectedResponse); - const [response] = await client.listBucketOperations(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBucketOperations without error using callback', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - ]; - client.innerApiCalls.listBucketOperations = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBucketOperations( - request, - (err?: Error|null, result?: protos.google.cloud.storagebatchoperations.v1.IBucketOperation[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBucketOperations with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listBucketOperations = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBucketOperations(request), expectedError); - const actualRequest = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listBucketOperations as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listBucketOperationsStream without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - ]; - client.descriptors.page.listBucketOperations.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBucketOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storagebatchoperations.v1.BucketOperation[] = []; - stream.on('data', (response: protos.google.cloud.storagebatchoperations.v1.BucketOperation) => { - 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.listBucketOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBucketOperations, request)); - assert( - (client.descriptors.page.listBucketOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listBucketOperationsStream with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBucketOperations.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBucketOperationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storagebatchoperations.v1.BucketOperation[] = []; - stream.on('data', (response: protos.google.cloud.storagebatchoperations.v1.BucketOperation) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBucketOperations.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBucketOperations, request)); - assert( - (client.descriptors.page.listBucketOperations.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBucketOperations without error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - generateSampleMessage(new protos.google.cloud.storagebatchoperations.v1.BucketOperation()), - ]; - client.descriptors.page.listBucketOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.storagebatchoperations.v1.IBucketOperation[] = []; - const iterable = client.listBucketOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getJob with closed client', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBucketOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBucketOperations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listBucketOperations with error', async () => { - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listBucketOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBucketOperationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.storagebatchoperations.v1.IBucketOperation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBucketOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listBucketOperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes deleteJob with closed client', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('cancelJob', () => { + it('invokes cancelJob without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CancelJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobResponse(), + ); + client.innerApiCalls.cancelJob = stubSimpleCall(expectedResponse); + const [response] = await client.cancelJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelJob without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CancelJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobResponse(), + ); + client.innerApiCalls.cancelJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storagebatchoperations.v1.ICancelJobResponse | 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelJob with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CancelJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.cancelJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes cancelJob with closed client', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CancelJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CancelJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.cancelJob(request), expectedError); + }); + }); + + describe('getBucketOperation', () => { + it('invokes getBucketOperation without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ); + client.innerApiCalls.getBucketOperation = + stubSimpleCall(expectedResponse); + const [response] = await client.getBucketOperation(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getBucketOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBucketOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes getBucketOperation without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ); + client.innerApiCalls.getBucketOperation = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBucketOperation( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storagebatchoperations.v1.IBucketOperation | 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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.getBucketOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBucketOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { + it('invokes getBucketOperation with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getBucketOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getBucketOperation(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getBucketOperation as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getBucketOperation as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('bucketOperation', async () => { - const fakePath = "/rendered/path/bucketOperation"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - bucket_operation: "bucketOperationValue", - }; - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.bucketOperationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.bucketOperationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('bucketOperationPath', () => { - const result = client.bucketOperationPath("projectValue", "locationValue", "jobValue", "bucketOperationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.bucketOperationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getBucketOperation with closed client', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.GetBucketOperationRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getBucketOperation(request), expectedError); + }); + }); + + describe('createJob', () => { + it('invokes createJob without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createJob = stubLongRunningCall(expectedResponse); + const [operation] = await client.createJob(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromBucketOperationName', () => { - const result = client.matchProjectFromBucketOperationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createJob without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createJob = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.storagebatchoperations.v1.IJob, + protos.google.cloud.storagebatchoperations.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromBucketOperationName', () => { - const result = client.matchLocationFromBucketOperationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createJob with call error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchJobFromBucketOperationName', () => { - const result = client.matchJobFromBucketOperationName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes createJob with LRO error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createJob(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchBucketOperationFromBucketOperationName', () => { - const result = client.matchBucketOperationFromBucketOperationName(fakePath); - assert.strictEqual(result, "bucketOperationValue"); - assert((client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes checkCreateJobProgress without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateJobProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - job: "jobValue", - }; - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "locationValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes checkCreateJobProgress with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkCreateJobProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listJobs without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + ]; + client.innerApiCalls.listJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.storagebatchoperations.v1.IJob[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchLocationFromJobName', () => { - const result = client.matchLocationFromJobName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listJobs with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes listJobsStream without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + ]; + client.descriptors.page.listJobs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storagebatchoperations.v1.Job[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storagebatchoperations.v1.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 listJobsStream with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storagebatchoperations.v1.Job[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storagebatchoperations.v1.Job) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].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('uses async iteration with listJobs without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.Job(), + ), + ]; + client.descriptors.page.listJobs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.storagebatchoperations.v1.IJob[] = + []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].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('uses async iteration with listJobs with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.storagebatchoperations.v1.IJob[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listBucketOperations', () => { + it('invokes listBucketOperations without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + ]; + client.innerApiCalls.listBucketOperations = + stubSimpleCall(expectedResponse); + const [response] = await client.listBucketOperations(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBucketOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBucketOperations 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ - 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 listBucketOperations without error using callback', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + ]; + client.innerApiCalls.listBucketOperations = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBucketOperations( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.storagebatchoperations.v1.IBucketOperation[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listBucketOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBucketOperations 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 listBucketOperations with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listBucketOperations = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listBucketOperations(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listBucketOperations as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listBucketOperations as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes listBucketOperationsStream without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + ]; + client.descriptors.page.listBucketOperations.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBucketOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storagebatchoperations.v1.BucketOperation[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.storagebatchoperations.v1.BucketOperation, + ) => { + 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.listBucketOperations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBucketOperations, request), + ); + assert( + (client.descriptors.page.listBucketOperations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('invokes listBucketOperationsStream with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBucketOperations.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listBucketOperationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storagebatchoperations.v1.BucketOperation[] = + []; + stream.on( + 'data', + ( + response: protos.google.cloud.storagebatchoperations.v1.BucketOperation, + ) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBucketOperations.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBucketOperations, request), + ); + assert( + (client.descriptors.page.listBucketOperations.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listBucketOperations without error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.BucketOperation(), + ), + ]; + client.descriptors.page.listBucketOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.storagebatchoperations.v1.IBucketOperation[] = + []; + const iterable = client.listBucketOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listBucketOperations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBucketOperations.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + + it('uses async iteration with listBucketOperations with error', async () => { + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storagebatchoperations.v1.ListBucketOperationsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listBucketOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBucketOperationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.storagebatchoperations.v1.IBucketOperation[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listBucketOperations.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listBucketOperations.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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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('bucketOperation', async () => { + const fakePath = '/rendered/path/bucketOperation'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + job: 'jobValue', + bucket_operation: 'bucketOperationValue', + }; + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.bucketOperationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.bucketOperationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('bucketOperationPath', () => { + const result = client.bucketOperationPath( + 'projectValue', + 'locationValue', + 'jobValue', + 'bucketOperationValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.bucketOperationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromBucketOperationName', () => { + const result = client.matchProjectFromBucketOperationName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromBucketOperationName', () => { + const result = client.matchLocationFromBucketOperationName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromBucketOperationName', () => { + const result = client.matchJobFromBucketOperationName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchBucketOperationFromBucketOperationName', () => { + const result = + client.matchBucketOperationFromBucketOperationName(fakePath); + assert.strictEqual(result, 'bucketOperationValue'); + assert( + (client.pathTemplates.bucketOperationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + job: 'jobValue', + }; + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'locationValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromJobName', () => { + const result = client.matchLocationFromJobName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('location', async () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = + new storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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 storagebatchoperationsModule.v1.StorageBatchOperationsClient({ + 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-storagebatchoperations/webpack.config.js b/packages/google-cloud-storagebatchoperations/webpack.config.js index ab88f0433a67..b6c2f0ea68dd 100644 --- a/packages/google-cloud-storagebatchoperations/webpack.config.js +++ b/packages/google-cloud-storagebatchoperations/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-storageinsights/.eslintignore b/packages/google-cloud-storageinsights/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-storageinsights/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-storageinsights/.eslintrc.json b/packages/google-cloud-storageinsights/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-storageinsights/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-storageinsights/README.md b/packages/google-cloud-storageinsights/README.md index c2f2963ee7f2..14ec7b07d29f 100644 --- a/packages/google-cloud-storageinsights/README.md +++ b/packages/google-cloud-storageinsights/README.md @@ -106,7 +106,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-storageinsights/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`) @@ -116,7 +116,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-storageinsights/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-storageinsights/protos/protos.d.ts b/packages/google-cloud-storageinsights/protos/protos.d.ts index fc745625949f..e8a66f449ed2 100644 --- a/packages/google-cloud-storageinsights/protos/protos.d.ts +++ b/packages/google-cloud-storageinsights/protos/protos.d.ts @@ -5245,6 +5245,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -5262,6 +5265,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 @@ -5962,6 +5968,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -5976,6 +5985,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 @@ -6054,6 +6066,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 { @@ -6380,6 +6504,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -6394,6 +6521,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 @@ -6718,6 +6848,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, @@ -7099,6 +7332,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -7129,6 +7363,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -7178,6 +7415,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -7312,6 +7552,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -7353,6 +7596,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 @@ -8200,6 +8446,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -8226,6 +8475,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 @@ -9160,6 +9412,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); @@ -9215,6 +9470,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[]; @@ -9435,6 +9693,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. */ @@ -9673,6 +10046,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -9695,6 +10071,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[]; @@ -10287,6 +10666,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. */ @@ -10316,6 +10701,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 @@ -10438,6 +10829,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. */ @@ -10557,8 +11058,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. */ @@ -10573,8 +11077,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. @@ -11107,6 +11614,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-storageinsights/protos/protos.js b/packages/google-cloud-storageinsights/protos/protos.js index f8d3c5ae6875..f386466a9f45 100644 --- a/packages/google-cloud-storageinsights/protos/protos.js +++ b/packages/google-cloud-storageinsights/protos/protos.js @@ -13217,6 +13217,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -13251,6 +13252,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 @@ -13283,6 +13292,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; }; @@ -13334,6 +13345,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; @@ -13385,6 +13400,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; }; @@ -13427,6 +13447,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; }; @@ -13445,8 +13470,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) { @@ -13454,6 +13481,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; }; @@ -15276,6 +15305,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -15301,6 +15331,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 @@ -15327,6 +15365,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; }; @@ -15367,6 +15407,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; @@ -15407,6 +15451,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; }; @@ -15427,6 +15476,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; }; @@ -15443,10 +15497,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; }; @@ -15476,6 +15534,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; })(); @@ -16352,6 +16662,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -16363,6 +16674,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) @@ -16377,6 +16689,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 @@ -16403,6 +16723,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; }; @@ -16433,7 +16756,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) @@ -16443,6 +16766,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; @@ -16483,6 +16829,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; }; @@ -16503,6 +16857,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; }; @@ -16519,10 +16880,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; }; @@ -17161,30 +17530,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; })(); /** @@ -18146,6 +18760,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 @@ -18160,6 +18775,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; @@ -18184,6 +18800,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 @@ -18206,6 +18823,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -18256,6 +18874,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 @@ -18377,6 +19003,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; }; @@ -18449,6 +19078,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 = []; @@ -18551,6 +19186,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"; @@ -18605,6 +19247,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -18657,6 +19300,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"); @@ -18720,6 +19370,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -18785,6 +19439,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -18841,6 +19496,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; }; @@ -18889,6 +19549,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 */ /** @@ -18994,6 +19655,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 @@ -19046,6 +19715,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; }; @@ -19138,6 +19809,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -19251,6 +19926,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; }; @@ -19350,6 +20034,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; }; @@ -19379,6 +20083,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; @@ -19424,6 +20129,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; }; @@ -21468,6 +22175,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 */ /** @@ -21528,6 +22236,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 @@ -21565,6 +22281,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; }; @@ -21627,6 +22345,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -21695,6 +22417,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; }; @@ -21744,6 +22475,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; }; @@ -21768,6 +22519,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; @@ -21788,6 +22540,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; }; @@ -24106,6 +24860,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 @@ -24226,6 +24981,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 @@ -24300,6 +25063,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(); @@ -24401,6 +25166,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 = []; @@ -24536,6 +25305,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"; @@ -24724,6 +25498,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"); @@ -24821,6 +25600,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")) @@ -24853,6 +25633,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) @@ -25125,6 +25907,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -25166,103 +25949,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; @@ -25857,6 +27126,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 */ @@ -25900,6 +27170,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 @@ -25938,6 +27216,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(); @@ -25989,6 +27269,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 = []; @@ -26041,6 +27325,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"; @@ -26074,6 +27363,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"); @@ -26106,6 +27400,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -26113,6 +27408,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) @@ -27580,6 +28877,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 */ /** @@ -27645,6 +28944,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 @@ -27681,6 +28996,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; }; @@ -27741,6 +29060,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; @@ -27831,6 +29158,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; }; @@ -27970,6 +29317,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; }; @@ -27993,6 +29388,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; @@ -28006,6 +29403,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; }; @@ -28133,6 +29534,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; })(); @@ -28317,6 +29931,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -28334,6 +29949,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -28382,6 +29998,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -28434,6 +30054,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -28542,7 +30166,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 */ /** @@ -28569,12 +30194,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. @@ -28600,10 +30233,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; }; @@ -28644,8 +30279,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: @@ -28688,6 +30327,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -28700,10 +30340,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; }; @@ -28731,6 +30376,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -28772,10 +30421,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; }; @@ -28794,13 +30448,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; }; @@ -30015,6 +31672,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-storageinsights/protos/protos.json b/packages/google-cloud-storageinsights/protos/protos.json index 849d9a93908a..90c1f289f02c 100644 --- a/packages/google-cloud-storageinsights/protos/protos.json +++ b/packages/google-cloud-storageinsights/protos/protos.json @@ -1424,8 +1424,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": { @@ -1549,6 +1548,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -1689,6 +1692,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 + } + } } } }, @@ -1746,6 +1771,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -1807,6 +1837,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -1939,12 +1982,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, @@ -1983,6 +2033,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -2071,6 +2126,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2296,6 +2355,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2346,7 +2409,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2510,6 +2580,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -2645,7 +2716,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -2673,6 +2745,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2742,6 +2818,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 + } + } } } }, @@ -2830,6 +2926,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -2972,6 +3072,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -2982,6 +3083,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -2992,6 +3094,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3002,6 +3105,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3012,7 +3116,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" } }, @@ -3022,27 +3127,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, @@ -3087,7 +3203,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -3102,6 +3224,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 + } + } + } } } }, @@ -3129,11 +3278,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -3146,6 +3310,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3231,6 +3401,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -3289,6 +3467,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-storageinsights/samples/generated/v1/snippet_metadata_google.cloud.storageinsights.v1.json b/packages/google-cloud-storageinsights/samples/generated/v1/snippet_metadata_google.cloud.storageinsights.v1.json index 3d22aeb91d91..a7cd56be32f1 100644 --- a/packages/google-cloud-storageinsights/samples/generated/v1/snippet_metadata_google.cloud.storageinsights.v1.json +++ b/packages/google-cloud-storageinsights/samples/generated/v1/snippet_metadata_google.cloud.storageinsights.v1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-storageinsights", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-storageinsights/src/v1/index.ts b/packages/google-cloud-storageinsights/src/v1/index.ts index 353f1ebdb1ff..52a810a5ceb2 100644 --- a/packages/google-cloud-storageinsights/src/v1/index.ts +++ b/packages/google-cloud-storageinsights/src/v1/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {StorageInsightsClient} from './storage_insights_client'; +export { StorageInsightsClient } from './storage_insights_client'; diff --git a/packages/google-cloud-storageinsights/src/v1/storage_insights_client.ts b/packages/google-cloud-storageinsights/src/v1/storage_insights_client.ts index 782ee6643c27..4b6c700d94c2 100644 --- a/packages/google-cloud-storageinsights/src/v1/storage_insights_client.ts +++ b/packages/google-cloud-storageinsights/src/v1/storage_insights_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 StorageInsightsClient { 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('storageinsights'); @@ -57,11 +68,11 @@ export class StorageInsightsClient { 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; - storageInsightsStub?: Promise<{[name: string]: Function}>; + storageInsightsStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of StorageInsightsClient. @@ -102,21 +113,42 @@ export class StorageInsightsClient { * const client = new StorageInsightsClient({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 StorageInsightsClient; - 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 = 'storageinsights.' + 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 StorageInsightsClient { 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 StorageInsightsClient { } 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,19 +213,19 @@ export class StorageInsightsClient { // Create useful helper objects for these. this.pathTemplates = { datasetConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/datasetConfigs/{dataset_config}' + 'projects/{project}/locations/{location}/datasetConfigs/{dataset_config}', ), locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), reportConfigPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/reportConfigs/{report_config}' + 'projects/{project}/locations/{location}/reportConfigs/{report_config}', ), reportDetailPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/reportConfigs/{report_config}/reportDetails/{report_detail}' + 'projects/{project}/locations/{location}/reportConfigs/{report_config}/reportDetails/{report_detail}', ), }; @@ -205,12 +233,21 @@ export class StorageInsightsClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listReportConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reportConfigs'), - listReportDetails: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'reportDetails'), - listDatasetConfigs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'datasetConfigs') + listReportConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'reportConfigs', + ), + listReportDetails: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'reportDetails', + ), + listDatasetConfigs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'datasetConfigs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -219,61 +256,107 @@ export class StorageInsightsClient { // 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 createDatasetConfigResponse = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.DatasetConfig') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.DatasetConfig', + ) as gax.protobuf.Type; const createDatasetConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.OperationMetadata', + ) as gax.protobuf.Type; const updateDatasetConfigResponse = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.DatasetConfig') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.DatasetConfig', + ) as gax.protobuf.Type; const updateDatasetConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.OperationMetadata', + ) as gax.protobuf.Type; const deleteDatasetConfigResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const deleteDatasetConfigMetadata = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.OperationMetadata', + ) as gax.protobuf.Type; const linkDatasetResponse = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.LinkDatasetResponse') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.LinkDatasetResponse', + ) as gax.protobuf.Type; const linkDatasetMetadata = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.OperationMetadata', + ) as gax.protobuf.Type; const unlinkDatasetResponse = protoFilesRoot.lookup( - '.google.protobuf.Empty') as gax.protobuf.Type; + '.google.protobuf.Empty', + ) as gax.protobuf.Type; const unlinkDatasetMetadata = protoFilesRoot.lookup( - '.google.cloud.storageinsights.v1.OperationMetadata') as gax.protobuf.Type; + '.google.cloud.storageinsights.v1.OperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { createDatasetConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createDatasetConfigResponse.decode.bind(createDatasetConfigResponse), - createDatasetConfigMetadata.decode.bind(createDatasetConfigMetadata)), + createDatasetConfigMetadata.decode.bind(createDatasetConfigMetadata), + ), updateDatasetConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateDatasetConfigResponse.decode.bind(updateDatasetConfigResponse), - updateDatasetConfigMetadata.decode.bind(updateDatasetConfigMetadata)), + updateDatasetConfigMetadata.decode.bind(updateDatasetConfigMetadata), + ), deleteDatasetConfig: new this._gaxModule.LongrunningDescriptor( this.operationsClient, deleteDatasetConfigResponse.decode.bind(deleteDatasetConfigResponse), - deleteDatasetConfigMetadata.decode.bind(deleteDatasetConfigMetadata)), + deleteDatasetConfigMetadata.decode.bind(deleteDatasetConfigMetadata), + ), linkDataset: new this._gaxModule.LongrunningDescriptor( this.operationsClient, linkDatasetResponse.decode.bind(linkDatasetResponse), - linkDatasetMetadata.decode.bind(linkDatasetMetadata)), + linkDatasetMetadata.decode.bind(linkDatasetMetadata), + ), unlinkDataset: new this._gaxModule.LongrunningDescriptor( this.operationsClient, unlinkDatasetResponse.decode.bind(unlinkDatasetResponse), - unlinkDatasetMetadata.decode.bind(unlinkDatasetMetadata)) + unlinkDatasetMetadata.decode.bind(unlinkDatasetMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.storageinsights.v1.StorageInsights', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.storageinsights.v1.StorageInsights', + 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 +387,48 @@ export class StorageInsightsClient { // Put together the "service stub" for // google.cloud.storageinsights.v1.StorageInsights. this.storageInsightsStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.storageinsights.v1.StorageInsights') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.storageinsights.v1.StorageInsights', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.storageinsights.v1.StorageInsights, - 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 storageInsightsStubMethods = - ['listReportConfigs', 'getReportConfig', 'createReportConfig', 'updateReportConfig', 'deleteReportConfig', 'listReportDetails', 'getReportDetail', 'listDatasetConfigs', 'getDatasetConfig', 'createDatasetConfig', 'updateDatasetConfig', 'deleteDatasetConfig', 'linkDataset', 'unlinkDataset']; + const storageInsightsStubMethods = [ + 'listReportConfigs', + 'getReportConfig', + 'createReportConfig', + 'updateReportConfig', + 'deleteReportConfig', + 'listReportDetails', + 'getReportDetail', + 'listDatasetConfigs', + 'getDatasetConfig', + 'createDatasetConfig', + 'updateDatasetConfig', + 'deleteDatasetConfig', + 'linkDataset', + 'unlinkDataset', + ]; for (const methodName of storageInsightsStubMethods) { const callPromise = this.storageInsightsStub.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 +438,7 @@ export class StorageInsightsClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -350,8 +453,14 @@ export class StorageInsightsClient { * @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 'storageinsights.googleapis.com'; } @@ -362,8 +471,14 @@ export class StorageInsightsClient { * @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 'storageinsights.googleapis.com'; } @@ -394,9 +509,7 @@ export class StorageInsightsClient { * @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 +518,9 @@ export class StorageInsightsClient { * 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,1294 +531,1923 @@ export class StorageInsightsClient { // ------------------- // -- Service calls -- // ------------------- -/** - * 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.storageinsights.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/storage_insights.get_report_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_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.storageinsights.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/storage_insights.get_report_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_GetReportConfig_async + */ getReportConfig( - request?: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.IGetReportConfigRequest + | undefined + ), + {} | undefined, + ] + >; getReportConfig( - request: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportConfig( - request: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportConfig( - request?: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.IGetReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IGetReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.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.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IGetReportConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.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.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.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.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.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; }); } -/** - * Creates a new ReportConfig 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 {google.cloud.storageinsights.v1.ReportConfig} request.reportConfig - * 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 {@link protos.google.cloud.storageinsights.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/storage_insights.create_report_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_CreateReportConfig_async - */ + /** + * Creates a new ReportConfig 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 {google.cloud.storageinsights.v1.ReportConfig} request.reportConfig + * 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 {@link protos.google.cloud.storageinsights.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/storage_insights.create_report_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_CreateReportConfig_async + */ createReportConfig( - request?: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | undefined + ), + {} | undefined, + ] + >; createReportConfig( - request: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createReportConfig( - request: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createReportConfig( - request?: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createReportConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createReportConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createReportConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('createReportConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createReportConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.ICreateReportConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createReportConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 ReportConfig. - * - * @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 - * ReportConfig 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.storageinsights.v1.ReportConfig} request.reportConfig - * 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.storageinsights.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/storage_insights.update_report_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_UpdateReportConfig_async - */ + /** + * Updates the parameters of a single ReportConfig. + * + * @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 + * ReportConfig 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.storageinsights.v1.ReportConfig} request.reportConfig + * 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.storageinsights.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/storage_insights.update_report_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_UpdateReportConfig_async + */ updateReportConfig( - request?: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | undefined + ), + {} | undefined, + ] + >; updateReportConfig( - request: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateReportConfig( - request: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateReportConfig( - request?: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'report_config.name': request.reportConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'report_config.name': request.reportConfig!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateReportConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storageinsights.v1.IReportConfig, + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateReportConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateReportConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storageinsights.v1.IReportConfig, - protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateReportConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateReportConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storageinsights.v1.IReportConfig, + ( + | protos.google.cloud.storageinsights.v1.IUpdateReportConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('updateReportConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 ReportConfig. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @param {boolean} [request.force] - * Optional. If set, all ReportDetails for this ReportConfig will be deleted. - * @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/storage_insights.delete_report_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_DeleteReportConfig_async - */ + /** + * Deletes a single ReportConfig. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @param {boolean} [request.force] + * Optional. If set, all ReportDetails for this ReportConfig will be deleted. + * @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/storage_insights.delete_report_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_DeleteReportConfig_async + */ deleteReportConfig( - request?: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | undefined + ), + {} | undefined, + ] + >; deleteReportConfig( - request: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteReportConfig( - request: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteReportConfig( - request?: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteReportConfig request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteReportConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteReportConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteReportConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteReportConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.storageinsights.v1.IDeleteReportConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('deleteReportConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 ReportDetail. - * - * @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.storageinsights.v1.ReportDetail|ReportDetail}. - * Please see the {@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/storage_insights.get_report_detail.js - * region_tag:storageinsights_v1_generated_StorageInsights_GetReportDetail_async - */ + /** + * Gets details of a single ReportDetail. + * + * @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.storageinsights.v1.ReportDetail|ReportDetail}. + * Please see the {@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/storage_insights.get_report_detail.js + * region_tag:storageinsights_v1_generated_StorageInsights_GetReportDetail_async + */ getReportDetail( - request?: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportDetail, + ( + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | undefined + ), + {} | undefined, + ] + >; getReportDetail( - request: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportDetail, + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportDetail( - request: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, - callback: Callback< - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, + callback: Callback< + protos.google.cloud.storageinsights.v1.IReportDetail, + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getReportDetail( - request?: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.IGetReportDetailRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storageinsights.v1.IReportDetail, + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportDetail, + ( + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getReportDetail request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|null|undefined, - {}|null|undefined>|undefined = callback - ? (error, response, options, rawResponse) => { + const wrappedCallback: + | Callback< + protos.google.cloud.storageinsights.v1.IReportDetail, + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { this._log.info('getReportDetail response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getReportDetail(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storageinsights.v1.IReportDetail, - protos.google.cloud.storageinsights.v1.IGetReportDetailRequest|undefined, - {}|undefined - ]) => { - this._log.info('getReportDetail response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getReportDetail(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storageinsights.v1.IReportDetail, + ( + | protos.google.cloud.storageinsights.v1.IGetReportDetailRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getReportDetail response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 dataset configuration in a given project for a given location. - * - * @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.storageinsights.v1.DatasetConfig|DatasetConfig}. - * Please see the {@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/storage_insights.get_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_GetDatasetConfig_async - */ + /** + * Gets the dataset configuration in a given project for a given location. + * + * @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.storageinsights.v1.DatasetConfig|DatasetConfig}. + * Please see the {@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/storage_insights.get_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_GetDatasetConfig_async + */ getDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IDatasetConfig, + ( + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | undefined + ), + {} | undefined, + ] + >; getDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, - callback: Callback< - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, + callback: Callback< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IDatasetConfig, + ( + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | undefined + ), + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getDatasetConfig request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getDatasetConfig response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getDatasetConfig(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.storageinsights.v1.IDatasetConfig, - protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest|undefined, - {}|undefined - ]) => { - this._log.info('getDatasetConfig response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getDatasetConfig(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.storageinsights.v1.IDatasetConfig, + ( + | protos.google.cloud.storageinsights.v1.IGetDatasetConfigRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('getDatasetConfig response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 dataset configuration in a given project for a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Value for parent. - * @param {string} request.datasetConfigId - * Required. ID of the requesting object. - * If auto-generating ID is enabled on the server-side, remove this field and - * `dataset_config_id` from the method_signature of Create RPC - * Note: The value should not contain any hyphens. - * @param {google.cloud.storageinsights.v1.DatasetConfig} request.datasetConfig - * Required. The resource being created - * @param {string} [request.requestId] - * Optional. A unique identifier for your request. - * Specify the request ID if you need to retry the request. - * If you retry the request with the same ID within 60 minutes, the server - * ignores the request if it has already completed the original request. - * - * For example, if your initial request times out and you retry the request - * using the same request ID, the server recognizes the original request and - * does not process the new request. - * - * The request ID must be a valid UUID and cannot be a zero UUID - * (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/storage_insights.create_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_CreateDatasetConfig_async - */ + /** + * Creates a dataset configuration in a given project for a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Value for parent. + * @param {string} request.datasetConfigId + * Required. ID of the requesting object. + * If auto-generating ID is enabled on the server-side, remove this field and + * `dataset_config_id` from the method_signature of Create RPC + * Note: The value should not contain any hyphens. + * @param {google.cloud.storageinsights.v1.DatasetConfig} request.datasetConfig + * Required. The resource being created + * @param {string} [request.requestId] + * Optional. A unique identifier for your request. + * Specify the request ID if you need to retry the request. + * If you retry the request with the same ID within 60 minutes, the server + * ignores the request if it has already completed the original request. + * + * For example, if your initial request times out and you retry the request + * using the same request ID, the server recognizes the original request and + * does not process the new request. + * + * The request ID must be a valid UUID and cannot be a zero UUID + * (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/storage_insights.create_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_CreateDatasetConfig_async + */ createDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; createDatasetConfig( - request: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDatasetConfig( - request: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; createDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storageinsights.v1.ICreateDatasetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.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.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('createDatasetConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('createDatasetConfig request %j', request); - return this.innerApiCalls.createDatasetConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('createDatasetConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .createDatasetConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createDatasetConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `createDatasetConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.create_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_CreateDatasetConfig_async - */ - async checkCreateDatasetConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `createDatasetConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.create_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_CreateDatasetConfig_async + */ + async checkCreateDatasetConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.storageinsights.v1.DatasetConfig, + protos.google.cloud.storageinsights.v1.OperationMetadata + > + > { this._log.info('createDatasetConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createDatasetConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.createDatasetConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.storageinsights.v1.DatasetConfig, + protos.google.cloud.storageinsights.v1.OperationMetadata + >; } -/** - * Updates a dataset configuration in a given project for a given location. - * - * @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 - * `DatasetConfig` 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 provide a mask then it returns an "Invalid Argument" error. - * @param {google.cloud.storageinsights.v1.DatasetConfig} request.datasetConfig - * Required. The resource being updated - * @param {string} [request.requestId] - * Optional. A unique identifier for your request. - * Specify the request ID if you need to retry the request. - * If you retry the request with the same ID within 60 minutes, the server - * ignores the request if it has already completed the original request. - * - * For example, if your initial request times out and you retry the request - * using the same request ID, the server recognizes the original request and - * does not process the new request. - * - * The request ID must be a valid UUID and cannot be a zero UUID - * (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/storage_insights.update_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_UpdateDatasetConfig_async - */ + /** + * Updates a dataset configuration in a given project for a given location. + * + * @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 + * `DatasetConfig` 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 provide a mask then it returns an "Invalid Argument" error. + * @param {google.cloud.storageinsights.v1.DatasetConfig} request.datasetConfig + * Required. The resource being updated + * @param {string} [request.requestId] + * Optional. A unique identifier for your request. + * Specify the request ID if you need to retry the request. + * If you retry the request with the same ID within 60 minutes, the server + * ignores the request if it has already completed the original request. + * + * For example, if your initial request times out and you retry the request + * using the same request ID, the server recognizes the original request and + * does not process the new request. + * + * The request ID must be a valid UUID and cannot be a zero UUID + * (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/storage_insights.update_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_UpdateDatasetConfig_async + */ updateDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; updateDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; updateDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storageinsights.v1.IUpdateDatasetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.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({ - 'dataset_config.name': request.datasetConfig!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'dataset_config.name': request.datasetConfig!.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.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('updateDatasetConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('updateDatasetConfig request %j', request); - return this.innerApiCalls.updateDatasetConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('updateDatasetConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .updateDatasetConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('updateDatasetConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `updateDatasetConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.update_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_UpdateDatasetConfig_async - */ - async checkUpdateDatasetConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `updateDatasetConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.update_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_UpdateDatasetConfig_async + */ + async checkUpdateDatasetConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.storageinsights.v1.DatasetConfig, + protos.google.cloud.storageinsights.v1.OperationMetadata + > + > { this._log.info('updateDatasetConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatasetConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.updateDatasetConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.storageinsights.v1.DatasetConfig, + protos.google.cloud.storageinsights.v1.OperationMetadata + >; } -/** - * Deletes a dataset configuration in a given project for a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the resource - * @param {string} [request.requestId] - * Optional. A unique identifier for your request. - * Specify the request ID if you need to retry the request. - * If you retry the request with the same ID within 60 minutes, the server - * ignores the request if it has already completed the original request. - * - * For example, if your initial request times out and you retry the request - * using the same request ID, the server recognizes the original request and - * does not process the new request. - * - * The request ID must be a valid UUID and cannot be a zero UUID - * (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/storage_insights.delete_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_DeleteDatasetConfig_async - */ + /** + * Deletes a dataset configuration in a given project for a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the resource + * @param {string} [request.requestId] + * Optional. A unique identifier for your request. + * Specify the request ID if you need to retry the request. + * If you retry the request with the same ID within 60 minutes, the server + * ignores the request if it has already completed the original request. + * + * For example, if your initial request times out and you retry the request + * using the same request ID, the server recognizes the original request and + * does not process the new request. + * + * The request ID must be a valid UUID and cannot be a zero UUID + * (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/storage_insights.delete_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_DeleteDatasetConfig_async + */ deleteDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; deleteDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDatasetConfig( - request: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; deleteDatasetConfig( - request?: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storageinsights.v1.IDeleteDatasetConfigRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.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.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('deleteDatasetConfig response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('deleteDatasetConfig request %j', request); - return this.innerApiCalls.deleteDatasetConfig(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('deleteDatasetConfig response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .deleteDatasetConfig(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteDatasetConfig response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `deleteDatasetConfig()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.delete_dataset_config.js - * region_tag:storageinsights_v1_generated_StorageInsights_DeleteDatasetConfig_async - */ - async checkDeleteDatasetConfigProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `deleteDatasetConfig()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.delete_dataset_config.js + * region_tag:storageinsights_v1_generated_StorageInsights_DeleteDatasetConfig_async + */ + async checkDeleteDatasetConfigProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.storageinsights.v1.OperationMetadata + > + > { this._log.info('deleteDatasetConfig long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.deleteDatasetConfig, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.deleteDatasetConfig, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.storageinsights.v1.OperationMetadata + >; } -/** - * Links a dataset to BigQuery in a given project for a given location. - * - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.link_dataset.js - * region_tag:storageinsights_v1_generated_StorageInsights_LinkDataset_async - */ + /** + * Links a dataset to BigQuery in a given project for a given location. + * + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.link_dataset.js + * region_tag:storageinsights_v1_generated_StorageInsights_LinkDataset_async + */ linkDataset( - request?: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; linkDataset( - request: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; linkDataset( - request: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, + callback: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; linkDataset( - request?: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storageinsights.v1.ILinkDatasetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.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.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('linkDataset response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('linkDataset request %j', request); - return this.innerApiCalls.linkDataset(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('linkDataset response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .linkDataset(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('linkDataset response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `linkDataset()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.link_dataset.js - * region_tag:storageinsights_v1_generated_StorageInsights_LinkDataset_async - */ - async checkLinkDatasetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `linkDataset()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.link_dataset.js + * region_tag:storageinsights_v1_generated_StorageInsights_LinkDataset_async + */ + async checkLinkDatasetProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.storageinsights.v1.LinkDatasetResponse, + protos.google.cloud.storageinsights.v1.OperationMetadata + > + > { this._log.info('linkDataset long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.linkDataset, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.linkDataset, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.storageinsights.v1.LinkDatasetResponse, + protos.google.cloud.storageinsights.v1.OperationMetadata + >; } -/** - * Unlinks a dataset from BigQuery in a given project - * for a given location. - * - * @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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.unlink_dataset.js - * region_tag:storageinsights_v1_generated_StorageInsights_UnlinkDataset_async - */ + /** + * Unlinks a dataset from BigQuery in a given project + * for a given location. + * + * @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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.unlink_dataset.js + * region_tag:storageinsights_v1_generated_StorageInsights_UnlinkDataset_async + */ unlinkDataset( - request?: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; unlinkDataset( - request: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; unlinkDataset( - request: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; unlinkDataset( - request?: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.storageinsights.v1.IUnlinkDatasetRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.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.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('unlinkDataset response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('unlinkDataset request %j', request); - return this.innerApiCalls.unlinkDataset(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('unlinkDataset response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .unlinkDataset(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('unlinkDataset response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `unlinkDataset()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v1/storage_insights.unlink_dataset.js - * region_tag:storageinsights_v1_generated_StorageInsights_UnlinkDataset_async - */ - async checkUnlinkDatasetProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `unlinkDataset()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v1/storage_insights.unlink_dataset.js + * region_tag:storageinsights_v1_generated_StorageInsights_UnlinkDataset_async + */ + async checkUnlinkDatasetProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.storageinsights.v1.OperationMetadata + > + > { this._log.info('unlinkDataset long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.unlinkDataset, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.unlinkDataset, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.cloud.storageinsights.v1.OperationMetadata + >; } - /** - * 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 - * 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.storageinsights.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 + * 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.storageinsights.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.storageinsights.v1.IListReportConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig[], - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse - ]>; + request?: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig[], + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest | null, + protos.google.cloud.storageinsights.v1.IListReportConfigsResponse, + ] + >; listReportConfigs( - request: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportConfig>): void; + request: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportConfig + >, + ): void; listReportConfigs( - request: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportConfig>): void; + request: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportConfig + >, + ): void; listReportConfigs( - request?: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportConfig>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportConfig[], - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse - ]>|void { + | protos.google.cloud.storageinsights.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportConfig + >, + callback?: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportConfig + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportConfig[], + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest | null, + protos.google.cloud.storageinsights.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.storageinsights.v1.IListReportConfigsRequest, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListReportConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listReportConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1713,204 +2456,233 @@ export class StorageInsightsClient { this._log.info('listReportConfigs request %j', request); return this.innerApiCalls .listReportConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.storageinsights.v1.IReportConfig[], - protos.google.cloud.storageinsights.v1.IListReportConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportConfigsResponse - ]) => { - this._log.info('listReportConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.storageinsights.v1.IReportConfig[], + protos.google.cloud.storageinsights.v1.IListReportConfigsRequest | null, + protos.google.cloud.storageinsights.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 - * 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.storageinsights.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 + * 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.storageinsights.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.storageinsights.v1.IListReportConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.storageinsights.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 - * 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.storageinsights.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/storage_insights.list_report_configs.js - * region_tag:storageinsights_v1_generated_StorageInsights_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 + * 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.storageinsights.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/storage_insights.list_report_configs.js + * region_tag:storageinsights_v1_generated_StorageInsights_ListReportConfigs_async + */ listReportConfigsAsync( - request?: protos.google.cloud.storageinsights.v1.IListReportConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.storageinsights.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 ReportDetails in a given project and location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListReportDetailsRequest - * @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 - * 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.storageinsights.v1.ReportDetail|ReportDetail}. - * 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 `listReportDetailsAsync()` - * method described below for async iteration which you can stop as 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 ReportDetails in a given project and location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListReportDetailsRequest + * @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 + * 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.storageinsights.v1.ReportDetail|ReportDetail}. + * 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 `listReportDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReportDetails( - request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportDetail[], - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse - ]>; + request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportDetail[], + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest | null, + protos.google.cloud.storageinsights.v1.IListReportDetailsResponse, + ] + >; listReportDetails( - request: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportDetail>): void; + request: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + | protos.google.cloud.storageinsights.v1.IListReportDetailsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportDetail + >, + ): void; listReportDetails( - request: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportDetail>): void; + request: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + | protos.google.cloud.storageinsights.v1.IListReportDetailsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportDetail + >, + ): void; listReportDetails( - request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportDetail>, - callback?: PaginationCallback< + request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportDetail>): - Promise<[ - protos.google.cloud.storageinsights.v1.IReportDetail[], - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse - ]>|void { + | protos.google.cloud.storageinsights.v1.IListReportDetailsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportDetail + >, + callback?: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + | protos.google.cloud.storageinsights.v1.IListReportDetailsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportDetail + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IReportDetail[], + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest | null, + protos.google.cloud.storageinsights.v1.IListReportDetailsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.storageinsights.v1.IListReportDetailsRequest, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IReportDetail>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + | protos.google.cloud.storageinsights.v1.IListReportDetailsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IReportDetail + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listReportDetails values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1919,204 +2691,233 @@ export class StorageInsightsClient { this._log.info('listReportDetails request %j', request); return this.innerApiCalls .listReportDetails(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.storageinsights.v1.IReportDetail[], - protos.google.cloud.storageinsights.v1.IListReportDetailsRequest|null, - protos.google.cloud.storageinsights.v1.IListReportDetailsResponse - ]) => { - this._log.info('listReportDetails values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.storageinsights.v1.IReportDetail[], + protos.google.cloud.storageinsights.v1.IListReportDetailsRequest | null, + protos.google.cloud.storageinsights.v1.IListReportDetailsResponse, + ]) => { + this._log.info('listReportDetails values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listReportDetails`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListReportDetailsRequest - * @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 - * 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.storageinsights.v1.ReportDetail|ReportDetail} 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 `listReportDetailsAsync()` - * method described below for async iteration which you can stop as 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 `listReportDetails`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListReportDetailsRequest + * @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 + * 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.storageinsights.v1.ReportDetail|ReportDetail} 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 `listReportDetailsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listReportDetailsStream( - request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + 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['listReportDetails']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReportDetails stream %j', request); return this.descriptors.page.listReportDetails.createStream( this.innerApiCalls.listReportDetails as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listReportDetails`, 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 ListReportDetailsRequest - * @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 - * 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.storageinsights.v1.ReportDetail|ReportDetail}. 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/storage_insights.list_report_details.js - * region_tag:storageinsights_v1_generated_StorageInsights_ListReportDetails_async - */ + /** + * Equivalent to `listReportDetails`, 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 ListReportDetailsRequest + * @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 + * 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.storageinsights.v1.ReportDetail|ReportDetail}. 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/storage_insights.list_report_details.js + * region_tag:storageinsights_v1_generated_StorageInsights_ListReportDetails_async + */ listReportDetailsAsync( - request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.storageinsights.v1.IListReportDetailsRequest, + 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['listReportDetails']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listReportDetails iterate %j', request); return this.descriptors.page.listReportDetails.asyncIterate( this.innerApiCalls['listReportDetails'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the dataset configurations in a given project for a given location. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListDatasetConfigsRequest - * @param {number} request.pageSize - * Requested page size. Server might return fewer items than requested. - * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig}. - * 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 `listDatasetConfigsAsync()` - * method described below for async iteration which you can stop as 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 dataset configurations in a given project for a given location. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListDatasetConfigsRequest + * @param {number} request.pageSize + * Requested page size. Server might return fewer items than requested. + * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig}. + * 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 `listDatasetConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatasetConfigs( - request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.storageinsights.v1.IDatasetConfig[], - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse - ]>; + request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IDatasetConfig[], + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest | null, + protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse, + ] + >; listDatasetConfigs( - request: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IDatasetConfig>): void; + request: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IDatasetConfig + >, + ): void; listDatasetConfigs( - request: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - callback: PaginationCallback< - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IDatasetConfig>): void; + request: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + callback: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IDatasetConfig + >, + ): void; listDatasetConfigs( - request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IDatasetConfig>, - callback?: PaginationCallback< + request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IDatasetConfig>): - Promise<[ - protos.google.cloud.storageinsights.v1.IDatasetConfig[], - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse - ]>|void { + | protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IDatasetConfig + >, + callback?: PaginationCallback< + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IDatasetConfig + >, + ): Promise< + [ + protos.google.cloud.storageinsights.v1.IDatasetConfig[], + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest | null, + protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.storageinsights.v1.IListDatasetConfigsRequest, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse|null|undefined, - protos.google.cloud.storageinsights.v1.IDatasetConfig>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + | protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse + | null + | undefined, + protos.google.cloud.storageinsights.v1.IDatasetConfig + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listDatasetConfigs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2125,119 +2926,124 @@ export class StorageInsightsClient { this._log.info('listDatasetConfigs request %j', request); return this.innerApiCalls .listDatasetConfigs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.storageinsights.v1.IDatasetConfig[], - protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest|null, - protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse - ]) => { - this._log.info('listDatasetConfigs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.storageinsights.v1.IDatasetConfig[], + protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest | null, + protos.google.cloud.storageinsights.v1.IListDatasetConfigsResponse, + ]) => { + this._log.info('listDatasetConfigs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listDatasetConfigs`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Parent value for ListDatasetConfigsRequest - * @param {number} request.pageSize - * Requested page size. Server might return fewer items than requested. - * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig} 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 `listDatasetConfigsAsync()` - * method described below for async iteration which you can stop as 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 `listDatasetConfigs`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Parent value for ListDatasetConfigsRequest + * @param {number} request.pageSize + * Requested page size. Server might return fewer items than requested. + * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig} 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 `listDatasetConfigsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listDatasetConfigsStream( - request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + 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['listDatasetConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatasetConfigs stream %j', request); return this.descriptors.page.listDatasetConfigs.createStream( this.innerApiCalls.listDatasetConfigs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listDatasetConfigs`, 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 ListDatasetConfigsRequest - * @param {number} request.pageSize - * Requested page size. Server might return fewer items than requested. - * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig}. 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/storage_insights.list_dataset_configs.js - * region_tag:storageinsights_v1_generated_StorageInsights_ListDatasetConfigs_async - */ + /** + * Equivalent to `listDatasetConfigs`, 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 ListDatasetConfigsRequest + * @param {number} request.pageSize + * Requested page size. Server might return fewer items than requested. + * If unspecified, server picks 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.storageinsights.v1.DatasetConfig|DatasetConfig}. 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/storage_insights.list_dataset_configs.js + * region_tag:storageinsights_v1_generated_StorageInsights_ListDatasetConfigs_async + */ listDatasetConfigsAsync( - request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.storageinsights.v1.IListDatasetConfigsRequest, + 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['listDatasetConfigs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listDatasetConfigs iterate %j', request); return this.descriptors.page.listDatasetConfigs.asyncIterate( this.innerApiCalls['listDatasetConfigs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2272,12 +3078,11 @@ export class StorageInsightsClient { | 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. @@ -2310,12 +3115,12 @@ export class StorageInsightsClient { */ 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. @@ -2358,22 +3163,22 @@ export class StorageInsightsClient { 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); } /** @@ -2408,15 +3213,15 @@ export class StorageInsightsClient { */ 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); } /** @@ -2450,7 +3255,7 @@ export class StorageInsightsClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2463,25 +3268,24 @@ export class StorageInsightsClient { 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 @@ -2520,22 +3324,22 @@ export class StorageInsightsClient { 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); } @@ -2551,7 +3355,7 @@ export class StorageInsightsClient { * @param {string} dataset_config * @returns {string} Resource name string. */ - datasetConfigPath(project:string,location:string,datasetConfig:string) { + datasetConfigPath(project: string, location: string, datasetConfig: string) { return this.pathTemplates.datasetConfigPathTemplate.render({ project: project, location: location, @@ -2567,7 +3371,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the project. */ matchProjectFromDatasetConfigName(datasetConfigName: string) { - return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName).project; + return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName) + .project; } /** @@ -2578,7 +3383,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the location. */ matchLocationFromDatasetConfigName(datasetConfigName: string) { - return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName).location; + return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName) + .location; } /** @@ -2589,7 +3395,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the dataset_config. */ matchDatasetConfigFromDatasetConfigName(datasetConfigName: string) { - return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName).dataset_config; + return this.pathTemplates.datasetConfigPathTemplate.match(datasetConfigName) + .dataset_config; } /** @@ -2599,7 +3406,7 @@ export class StorageInsightsClient { * @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, @@ -2634,7 +3441,7 @@ export class StorageInsightsClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2659,7 +3466,7 @@ export class StorageInsightsClient { * @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, @@ -2675,7 +3482,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the project. */ matchProjectFromReportConfigName(reportConfigName: string) { - return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName).project; + return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName) + .project; } /** @@ -2686,7 +3494,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the location. */ matchLocationFromReportConfigName(reportConfigName: string) { - return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName).location; + return this.pathTemplates.reportConfigPathTemplate.match(reportConfigName) + .location; } /** @@ -2697,7 +3506,8 @@ export class StorageInsightsClient { * @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; } /** @@ -2709,7 +3519,12 @@ export class StorageInsightsClient { * @param {string} report_detail * @returns {string} Resource name string. */ - reportDetailPath(project:string,location:string,reportConfig:string,reportDetail:string) { + reportDetailPath( + project: string, + location: string, + reportConfig: string, + reportDetail: string, + ) { return this.pathTemplates.reportDetailPathTemplate.render({ project: project, location: location, @@ -2726,7 +3541,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the project. */ matchProjectFromReportDetailName(reportDetailName: string) { - return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName).project; + return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName) + .project; } /** @@ -2737,7 +3553,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the location. */ matchLocationFromReportDetailName(reportDetailName: string) { - return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName).location; + return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName) + .location; } /** @@ -2748,7 +3565,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the report_config. */ matchReportConfigFromReportDetailName(reportDetailName: string) { - return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName).report_config; + return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName) + .report_config; } /** @@ -2759,7 +3577,8 @@ export class StorageInsightsClient { * @returns {string} A string representing the report_detail. */ matchReportDetailFromReportDetailName(reportDetailName: string) { - return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName).report_detail; + return this.pathTemplates.reportDetailPathTemplate.match(reportDetailName) + .report_detail; } /** @@ -2770,14 +3589,16 @@ export class StorageInsightsClient { */ close(): Promise { if (this.storageInsightsStub && !this._terminated) { - return this.storageInsightsStub.then(stub => { + return this.storageInsightsStub.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-storageinsights/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-storageinsights/system-test/fixtures/sample/src/index.ts index e9aa57d01b2b..03648d3aad96 100644 --- a/packages/google-cloud-storageinsights/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-storageinsights/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 {StorageInsightsClient} from '@google-cloud/storageinsights'; +import { StorageInsightsClient } from '@google-cloud/storageinsights'; // check that the client class type name can be used function doStuffWithStorageInsightsClient(client: StorageInsightsClient) { diff --git a/packages/google-cloud-storageinsights/system-test/install.ts b/packages/google-cloud-storageinsights/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-storageinsights/system-test/install.ts +++ b/packages/google-cloud-storageinsights/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-storageinsights/test/gapic_storage_insights_v1.ts b/packages/google-cloud-storageinsights/test/gapic_storage_insights_v1.ts index af5e6b7fd6ad..e4fd7c8bf548 100644 --- a/packages/google-cloud-storageinsights/test/gapic_storage_insights_v1.ts +++ b/packages/google-cloud-storageinsights/test/gapic_storage_insights_v1.ts @@ -19,3058 +19,3910 @@ 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 storageinsightsModule 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.StorageInsightsClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'storageinsights.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient(); - 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 = storageinsightsModule.v1.StorageInsightsClient.servicePath; - assert.strictEqual(servicePath, 'storageinsights.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = storageinsightsModule.v1.StorageInsightsClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'storageinsights.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storageinsights.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storageinsights.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 storageinsightsModule.v1.StorageInsightsClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = storageinsightsModule.v1.StorageInsightsClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.storageInsightsStub, undefined); - await client.initialize(); - assert(client.storageInsightsStub); - }); - - it('has close method for the initialized client', done => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.storageInsightsStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.storageInsightsStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'storageinsights.googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - 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 universeDomain', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - 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' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + storageinsightsModule.v1.StorageInsightsClient.servicePath; + assert.strictEqual(servicePath, 'storageinsights.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + storageinsightsModule.v1.StorageInsightsClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'storageinsights.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storageinsights.example.com'); }); - describe('getReportConfig', () => { - it('invokes getReportConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.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('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storageinsights.example.com'); + }); - it('invokes getReportConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportConfig() - ); - client.innerApiCalls.getReportConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReportConfig( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.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)); + 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 storageinsightsModule.v1.StorageInsightsClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes getReportConfig with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.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('has port', () => { + const port = storageinsightsModule.v1.StorageInsightsClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes getReportConfig with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.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('should create a client with no option', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient(); + assert(client); }); - describe('createReportConfig', () => { - it('invokes createReportConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportConfig() - ); - client.innerApiCalls.createReportConfig = stubSimpleCall(expectedResponse); - const [response] = await client.createReportConfig(request); - 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('should create a client with gRPC fallback', () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + fallback: true, + }); + assert(client); + }); - it('invokes createReportConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportConfig() - ); - client.innerApiCalls.createReportConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createReportConfig( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IReportConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await 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('has initialize method and supports deferred initialization', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.storageInsightsStub, undefined); + await client.initialize(); + assert(client.storageInsightsStub); + }); - it('invokes createReportConfig with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createReportConfig = stubSimpleCall(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('has close method for the initialized client', (done) => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.storageInsightsStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createReportConfig with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateReportConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createReportConfig(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.storageInsightsStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateReportConfig', () => { - it('invokes updateReportConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest() - ); - request.reportConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateReportConfigRequest', ['reportConfig', 'name']); - request.reportConfig.name = defaultValue1; - const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportConfig() - ); - client.innerApiCalls.updateReportConfig = stubSimpleCall(expectedResponse); - const [response] = await client.updateReportConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReportConfig 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 updateReportConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest() - ); - request.reportConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateReportConfigRequest', ['reportConfig', 'name']); - request.reportConfig.name = defaultValue1; - const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportConfig() - ); - client.innerApiCalls.updateReportConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateReportConfig( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IReportConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReportConfig 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 storageinsightsModule.v1.StorageInsightsClient({ + 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('getReportConfig', () => { + it('invokes getReportConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.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 updateReportConfig with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest() - ); - request.reportConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateReportConfigRequest', ['reportConfig', 'name']); - request.reportConfig.name = defaultValue1; - const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateReportConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateReportConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateReportConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateReportConfig 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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ); + client.innerApiCalls.getReportConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReportConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storageinsights.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 updateReportConfig with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest() - ); - request.reportConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateReportConfigRequest', ['reportConfig', 'name']); - request.reportConfig.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateReportConfig(request), expectedError); - }); + it('invokes getReportConfig with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.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('deleteReportConfig', () => { - it('invokes deleteReportConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReportConfig = stubSimpleCall(expectedResponse); - const [response] = await client.deleteReportConfig(request); - 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 getReportConfig with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.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('createReportConfig', () => { + it('invokes createReportConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ); + client.innerApiCalls.createReportConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.createReportConfig(request); + 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 deleteReportConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteReportConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteReportConfig( - 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.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 createReportConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ); + client.innerApiCalls.createReportConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createReportConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storageinsights.v1.IReportConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await 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 deleteReportConfig with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteReportConfig = stubSimpleCall(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 createReportConfig with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createReportConfig = stubSimpleCall( + 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 deleteReportConfig with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteReportConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteReportConfig(request), expectedError); - }); + it('invokes createReportConfig with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateReportConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createReportConfig(request), expectedError); + }); + }); + + describe('updateReportConfig', () => { + it('invokes updateReportConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest(), + ); + request.reportConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateReportConfigRequest', + ['reportConfig', 'name'], + ); + request.reportConfig.name = defaultValue1; + const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ); + client.innerApiCalls.updateReportConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.updateReportConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getReportDetail', () => { - it('invokes getReportDetail without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportDetailRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportDetailRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportDetail() - ); - client.innerApiCalls.getReportDetail = stubSimpleCall(expectedResponse); - const [response] = await client.getReportDetail(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateReportConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest(), + ); + request.reportConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateReportConfigRequest', + ['reportConfig', 'name'], + ); + request.reportConfig.name = defaultValue1; + const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ); + client.innerApiCalls.updateReportConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateReportConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storageinsights.v1.IReportConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReportDetail without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportDetailRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportDetailRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ReportDetail() - ); - client.innerApiCalls.getReportDetail = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getReportDetail( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IReportDetail|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateReportConfig with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest(), + ); + request.reportConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateReportConfigRequest', + ['reportConfig', 'name'], + ); + request.reportConfig.name = defaultValue1; + const expectedHeaderRequestParams = `report_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateReportConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateReportConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateReportConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getReportDetail with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportDetailRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportDetailRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getReportDetail = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getReportDetail(request), expectedError); - const actualRequest = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getReportDetail as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateReportConfig with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateReportConfigRequest(), + ); + request.reportConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateReportConfigRequest', + ['reportConfig', 'name'], + ); + request.reportConfig.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateReportConfig(request), expectedError); + }); + }); + + describe('deleteReportConfig', () => { + it('invokes deleteReportConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteReportConfig = + stubSimpleCall(expectedResponse); + const [response] = await client.deleteReportConfig(request); + 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 getReportDetail with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetReportDetailRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetReportDetailRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getReportDetail(request), expectedError); - }); + it('invokes deleteReportConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteReportConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteReportConfig( + 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.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)); }); - describe('getDatasetConfig', () => { - it('invokes getDatasetConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DatasetConfig() - ); - client.innerApiCalls.getDatasetConfig = stubSimpleCall(expectedResponse); - const [response] = await client.getDatasetConfig(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReportConfig with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteReportConfig = stubSimpleCall( + 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 getDatasetConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DatasetConfig() - ); - client.innerApiCalls.getDatasetConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDatasetConfig( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IDatasetConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteReportConfig with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteReportConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteReportConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteReportConfig(request), expectedError); + }); + }); + + describe('getReportDetail', () => { + it('invokes getReportDetail without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportDetailRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportDetailRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ); + client.innerApiCalls.getReportDetail = stubSimpleCall(expectedResponse); + const [response] = await client.getReportDetail(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDatasetConfig with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getDatasetConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDatasetConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReportDetail without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportDetailRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportDetailRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ); + client.innerApiCalls.getReportDetail = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getReportDetail( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storageinsights.v1.IReportDetail | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getDatasetConfig with closed client', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.GetDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getDatasetConfig(request), expectedError); - }); + it('invokes getReportDetail with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportDetailRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportDetailRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getReportDetail = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getReportDetail(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getReportDetail as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createDatasetConfig', () => { - it('invokes createDatasetConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatasetConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.createDatasetConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getReportDetail with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetReportDetailRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetReportDetailRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getReportDetail(request), expectedError); + }); + }); + + describe('getDatasetConfig', () => { + it('invokes getDatasetConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ); + client.innerApiCalls.getDatasetConfig = stubSimpleCall(expectedResponse); + const [response] = await client.getDatasetConfig(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDatasetConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.createDatasetConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDatasetConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatasetConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ); + client.innerApiCalls.getDatasetConfig = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDatasetConfig( + request, + ( + err?: Error | null, + result?: protos.google.cloud.storageinsights.v1.IDatasetConfig | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDatasetConfig with call error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatasetConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createDatasetConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatasetConfig with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getDatasetConfig = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getDatasetConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createDatasetConfig with LRO error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createDatasetConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createDatasetConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getDatasetConfig with closed client', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.GetDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.GetDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getDatasetConfig(request), expectedError); + }); + }); + + describe('createDatasetConfig', () => { + it('invokes createDatasetConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDatasetConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createDatasetConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateDatasetConfigProgress without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateDatasetConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createDatasetConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.createDatasetConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDatasetConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkCreateDatasetConfigProgress with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateDatasetConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createDatasetConfig with call error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatasetConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.createDatasetConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateDatasetConfig', () => { - it('invokes updateDatasetConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest() - ); - request.datasetConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', ['datasetConfig', 'name']); - request.datasetConfig.name = defaultValue1; - const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDatasetConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateDatasetConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createDatasetConfig with LRO error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.CreateDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.CreateDatasetConfigRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createDatasetConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.createDatasetConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDatasetConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest() - ); - request.datasetConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', ['datasetConfig', 'name']); - request.datasetConfig.name = defaultValue1; - const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.updateDatasetConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDatasetConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateDatasetConfigProgress without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateDatasetConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes updateDatasetConfig with call error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest() - ); - request.datasetConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', ['datasetConfig', 'name']); - request.datasetConfig.name = defaultValue1; - const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatasetConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateDatasetConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkCreateDatasetConfigProgress with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkCreateDatasetConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateDatasetConfig', () => { + it('invokes updateDatasetConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest(), + ); + request.datasetConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', + ['datasetConfig', 'name'], + ); + request.datasetConfig.name = defaultValue1; + const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDatasetConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateDatasetConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateDatasetConfig with LRO error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest() - ); - request.datasetConfig ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', ['datasetConfig', 'name']); - request.datasetConfig.name = defaultValue1; - const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDatasetConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateDatasetConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateDatasetConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest(), + ); + request.datasetConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', + ['datasetConfig', 'name'], + ); + request.datasetConfig.name = defaultValue1; + const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.updateDatasetConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDatasetConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.storageinsights.v1.IDatasetConfig, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateDatasetConfigProgress without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateDatasetConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes updateDatasetConfig with call error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest(), + ); + request.datasetConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', + ['datasetConfig', 'name'], + ); + request.datasetConfig.name = defaultValue1; + const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatasetConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateDatasetConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkUpdateDatasetConfigProgress with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateDatasetConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes updateDatasetConfig with LRO error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest(), + ); + request.datasetConfig ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UpdateDatasetConfigRequest', + ['datasetConfig', 'name'], + ); + request.datasetConfig.name = defaultValue1; + const expectedHeaderRequestParams = `dataset_config.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDatasetConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.updateDatasetConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteDatasetConfig', () => { - it('invokes deleteDatasetConfig without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDatasetConfig = stubLongRunningCall(expectedResponse); - const [operation] = await client.deleteDatasetConfig(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateDatasetConfigProgress without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateDatasetConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes deleteDatasetConfig without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.deleteDatasetConfig = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDatasetConfig( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUpdateDatasetConfigProgress with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUpdateDatasetConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('deleteDatasetConfig', () => { + it('invokes deleteDatasetConfig without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDatasetConfig = + stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteDatasetConfig(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDatasetConfig with call error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDatasetConfig = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.deleteDatasetConfig(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDatasetConfig without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteDatasetConfig = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDatasetConfig( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteDatasetConfig with LRO error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDatasetConfig = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.deleteDatasetConfig(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteDatasetConfig as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteDatasetConfig with call error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDatasetConfig = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteDatasetConfig(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteDatasetConfigProgress without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkDeleteDatasetConfigProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes deleteDatasetConfig with LRO error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.DeleteDatasetConfigRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDatasetConfig = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteDatasetConfig(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteDatasetConfig as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkDeleteDatasetConfigProgress with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkDeleteDatasetConfigProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkDeleteDatasetConfigProgress without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkDeleteDatasetConfigProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('linkDataset', () => { - it('invokes linkDataset without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.LinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.LinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.linkDataset = stubLongRunningCall(expectedResponse); - const [operation] = await client.linkDataset(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkDeleteDatasetConfigProgress with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkDeleteDatasetConfigProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('linkDataset', () => { + it('invokes linkDataset without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.LinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.LinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.linkDataset = stubLongRunningCall(expectedResponse); + const [operation] = await client.linkDataset(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes linkDataset without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.LinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.LinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.linkDataset = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.linkDataset( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes linkDataset without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.LinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.LinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.linkDataset = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.linkDataset( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.storageinsights.v1.ILinkDatasetResponse, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes linkDataset with call error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.LinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.LinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.linkDataset = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.linkDataset(request), expectedError); - const actualRequest = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes linkDataset with call error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.LinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.LinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.linkDataset = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.linkDataset(request), expectedError); + const actualRequest = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes linkDataset with LRO error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.LinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.LinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.linkDataset = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.linkDataset(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.linkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes linkDataset with LRO error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.LinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.LinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.linkDataset = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.linkDataset(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.linkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkLinkDatasetProgress without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkLinkDatasetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkLinkDatasetProgress without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkLinkDatasetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkLinkDatasetProgress with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkLinkDatasetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkLinkDatasetProgress with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkLinkDatasetProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('unlinkDataset', () => { + it('invokes unlinkDataset without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UnlinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.unlinkDataset = + stubLongRunningCall(expectedResponse); + const [operation] = await client.unlinkDataset(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('unlinkDataset', () => { - it('invokes unlinkDataset without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UnlinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.unlinkDataset = stubLongRunningCall(expectedResponse); - const [operation] = await client.unlinkDataset(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unlinkDataset without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UnlinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.unlinkDataset = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.unlinkDataset( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.cloud.storageinsights.v1.IOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unlinkDataset without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UnlinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.unlinkDataset = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.unlinkDataset( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unlinkDataset with call error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UnlinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.unlinkDataset = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.unlinkDataset(request), expectedError); + const actualRequest = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unlinkDataset with call error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UnlinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.unlinkDataset = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.unlinkDataset(request), expectedError); - const actualRequest = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes unlinkDataset with LRO error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.UnlinkDatasetRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.unlinkDataset = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.unlinkDataset(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.unlinkDataset as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes unlinkDataset with LRO error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.UnlinkDatasetRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.UnlinkDatasetRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.unlinkDataset = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.unlinkDataset(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.unlinkDataset as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkUnlinkDatasetProgress without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUnlinkDatasetProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkUnlinkDatasetProgress without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUnlinkDatasetProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkUnlinkDatasetProgress with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkUnlinkDatasetProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listReportConfigs', () => { + it('invokes listReportConfigs without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.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 checkUnlinkDatasetProgress with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUnlinkDatasetProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listReportConfigs without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + ]; + client.innerApiCalls.listReportConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReportConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.storageinsights.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)); }); - describe('listReportConfigs', () => { - it('invokes listReportConfigs without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - ]; - client.innerApiCalls.listReportConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReportConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.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.storageinsights.v1.ReportConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.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.storageinsights.v1.ReportConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.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.storageinsights.v1.ReportConfig[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportConfig(), + ), + ]; + client.descriptors.page.listReportConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.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.storageinsights.v1.ReportConfig[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.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 storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.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.storageinsights.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('listReportDetails', () => { + it('invokes listReportDetails without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + ]; + client.innerApiCalls.listReportDetails = stubSimpleCall(expectedResponse); + const [response] = await client.listReportDetails(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listReportDetails as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportDetails 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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportConfig()), - ]; - client.descriptors.page.listReportConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.storageinsights.v1.IReportConfig[] = []; - const iterable = client.listReportConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listReportDetails without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + ]; + client.innerApiCalls.listReportDetails = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listReportDetails( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.storageinsights.v1.IReportDetail[] + | 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 storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.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.storageinsights.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.listReportDetails as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportDetails as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listReportDetails', () => { - it('invokes listReportDetails without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - ]; - client.innerApiCalls.listReportDetails = stubSimpleCall(expectedResponse); - const [response] = await client.listReportDetails(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportDetails with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listReportDetails = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listReportDetails(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listReportDetails as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listReportDetails as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listReportDetails without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - ]; - client.innerApiCalls.listReportDetails = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listReportDetails( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IReportDetail[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportDetailsStream without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + ]; + client.descriptors.page.listReportDetails.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listReportDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storageinsights.v1.ReportDetail[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.v1.ReportDetail) => { + 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.listReportDetails.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReportDetails, request), + ); + assert( + (client.descriptors.page.listReportDetails.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportDetails with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listReportDetails = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listReportDetails(request), expectedError); - const actualRequest = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listReportDetails as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listReportDetailsStream with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReportDetails.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listReportDetailsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storageinsights.v1.ReportDetail[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.v1.ReportDetail) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listReportDetails.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listReportDetails, request), + ); + assert( + (client.descriptors.page.listReportDetails.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportDetailsStream without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - ]; - client.descriptors.page.listReportDetails.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listReportDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storageinsights.v1.ReportDetail[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.v1.ReportDetail) => { - 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.listReportDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReportDetails, request)); - assert( - (client.descriptors.page.listReportDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReportDetails without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ReportDetail(), + ), + ]; + client.descriptors.page.listReportDetails.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.storageinsights.v1.IReportDetail[] = + []; + const iterable = client.listReportDetailsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listReportDetails.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReportDetails.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listReportDetailsStream with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReportDetails.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listReportDetailsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storageinsights.v1.ReportDetail[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.v1.ReportDetail) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listReportDetails.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listReportDetails, request)); - assert( - (client.descriptors.page.listReportDetails.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listReportDetails with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListReportDetailsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listReportDetails.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listReportDetailsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.storageinsights.v1.IReportDetail[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listReportDetails.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listReportDetails.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listDatasetConfigs', () => { + it('invokes listDatasetConfigs without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + ]; + client.innerApiCalls.listDatasetConfigs = + stubSimpleCall(expectedResponse); + const [response] = await client.listDatasetConfigs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listDatasetConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasetConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listReportDetails without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.ReportDetail()), - ]; - client.descriptors.page.listReportDetails.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.storageinsights.v1.IReportDetail[] = []; - const iterable = client.listReportDetailsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listDatasetConfigs without error using callback', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + ]; + client.innerApiCalls.listDatasetConfigs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDatasetConfigs( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.storageinsights.v1.IDatasetConfig[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listReportDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReportDetails.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listReportDetails with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListReportDetailsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListReportDetailsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listReportDetails.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listReportDetailsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.storageinsights.v1.IReportDetail[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listReportDetails.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listReportDetails.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.listDatasetConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasetConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listDatasetConfigs', () => { - it('invokes listDatasetConfigs without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - ]; - client.innerApiCalls.listDatasetConfigs = stubSimpleCall(expectedResponse); - const [response] = await client.listDatasetConfigs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatasetConfigs without error using callback', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - ]; - client.innerApiCalls.listDatasetConfigs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDatasetConfigs( - request, - (err?: Error|null, result?: protos.google.cloud.storageinsights.v1.IDatasetConfig[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listDatasetConfigs with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listDatasetConfigs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDatasetConfigs(request), expectedError); - const actualRequest = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listDatasetConfigs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listDatasetConfigs with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listDatasetConfigs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listDatasetConfigs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listDatasetConfigs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listDatasetConfigs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listDatasetConfigsStream without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - ]; - client.descriptors.page.listDatasetConfigs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDatasetConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storageinsights.v1.DatasetConfig[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.v1.DatasetConfig) => { - 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.listDatasetConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatasetConfigs, request)); - assert( - (client.descriptors.page.listDatasetConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDatasetConfigsStream without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + ]; + client.descriptors.page.listDatasetConfigs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listDatasetConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storageinsights.v1.DatasetConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.v1.DatasetConfig) => { + 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.listDatasetConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDatasetConfigs, request), + ); + assert( + (client.descriptors.page.listDatasetConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listDatasetConfigsStream with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatasetConfigs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDatasetConfigsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.storageinsights.v1.DatasetConfig[] = []; - stream.on('data', (response: protos.google.cloud.storageinsights.v1.DatasetConfig) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDatasetConfigs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDatasetConfigs, request)); - assert( - (client.descriptors.page.listDatasetConfigs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listDatasetConfigsStream with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatasetConfigs.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listDatasetConfigsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.storageinsights.v1.DatasetConfig[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.storageinsights.v1.DatasetConfig) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listDatasetConfigs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listDatasetConfigs, request), + ); + assert( + (client.descriptors.page.listDatasetConfigs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDatasetConfigs without error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - generateSampleMessage(new protos.google.cloud.storageinsights.v1.DatasetConfig()), - ]; - client.descriptors.page.listDatasetConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.storageinsights.v1.IDatasetConfig[] = []; - const iterable = client.listDatasetConfigsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatasetConfigs without error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + generateSampleMessage( + new protos.google.cloud.storageinsights.v1.DatasetConfig(), + ), + ]; + client.descriptors.page.listDatasetConfigs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.storageinsights.v1.IDatasetConfig[] = + []; + const iterable = client.listDatasetConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listDatasetConfigs with error', async () => { - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listDatasetConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDatasetConfigsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.storageinsights.v1.IDatasetConfig[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listDatasetConfigs with error', async () => { + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.storageinsights.v1.ListDatasetConfigsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.storageinsights.v1.ListDatasetConfigsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listDatasetConfigs.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDatasetConfigsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.storageinsights.v1.IDatasetConfig[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listDatasetConfigs.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listDatasetConfigs.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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ + 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('datasetConfig', async () => { + const fakePath = '/rendered/path/datasetConfig'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + dataset_config: 'datasetConfigValue', + }; + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.datasetConfigPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.datasetConfigPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('datasetConfigPath', () => { + const result = client.datasetConfigPath( + 'projectValue', + 'locationValue', + 'datasetConfigValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.datasetConfigPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromDatasetConfigName', () => { + const result = client.matchProjectFromDatasetConfigName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromDatasetConfigName', () => { + const result = client.matchLocationFromDatasetConfigName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchDatasetConfigFromDatasetConfigName', () => { + const result = client.matchDatasetConfigFromDatasetConfigName(fakePath); + assert.strictEqual(result, 'datasetConfigValue'); + assert( + (client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('datasetConfig', async () => { - const fakePath = "/rendered/path/datasetConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - dataset_config: "datasetConfigValue", - }; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.datasetConfigPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.datasetConfigPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('datasetConfigPath', () => { - const result = client.datasetConfigPath("projectValue", "locationValue", "datasetConfigValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.datasetConfigPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDatasetConfigName', () => { - const result = client.matchProjectFromDatasetConfigName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDatasetConfigName', () => { - const result = client.matchLocationFromDatasetConfigName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDatasetConfigFromDatasetConfigName', () => { - const result = client.matchDatasetConfigFromDatasetConfigName(fakePath); - assert.strictEqual(result, "datasetConfigValue"); - assert((client.pathTemplates.datasetConfigPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', async () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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 storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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('reportConfig', async () => { - const fakePath = "/rendered/path/reportConfig"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - report_config: "reportConfigValue", - }; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - 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 storageinsightsModule.v1.StorageInsightsClient({ + 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('reportDetail', async () => { - const fakePath = "/rendered/path/reportDetail"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - report_config: "reportConfigValue", - report_detail: "reportDetailValue", - }; - const client = new storageinsightsModule.v1.StorageInsightsClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.reportDetailPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.reportDetailPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('reportDetailPath', () => { - const result = client.reportDetailPath("projectValue", "locationValue", "reportConfigValue", "reportDetailValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.reportDetailPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromReportDetailName', () => { - const result = client.matchProjectFromReportDetailName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.reportDetailPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromReportDetailName', () => { - const result = client.matchLocationFromReportDetailName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.reportDetailPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReportConfigFromReportDetailName', () => { - const result = client.matchReportConfigFromReportDetailName(fakePath); - assert.strictEqual(result, "reportConfigValue"); - assert((client.pathTemplates.reportDetailPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchReportDetailFromReportDetailName', () => { - const result = client.matchReportDetailFromReportDetailName(fakePath); - assert.strictEqual(result, "reportDetailValue"); - assert((client.pathTemplates.reportDetailPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('reportDetail', async () => { + const fakePath = '/rendered/path/reportDetail'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + report_config: 'reportConfigValue', + report_detail: 'reportDetailValue', + }; + const client = new storageinsightsModule.v1.StorageInsightsClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.reportDetailPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.reportDetailPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('reportDetailPath', () => { + const result = client.reportDetailPath( + 'projectValue', + 'locationValue', + 'reportConfigValue', + 'reportDetailValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.reportDetailPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromReportDetailName', () => { + const result = client.matchProjectFromReportDetailName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.reportDetailPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromReportDetailName', () => { + const result = client.matchLocationFromReportDetailName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.reportDetailPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReportConfigFromReportDetailName', () => { + const result = client.matchReportConfigFromReportDetailName(fakePath); + assert.strictEqual(result, 'reportConfigValue'); + assert( + (client.pathTemplates.reportDetailPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchReportDetailFromReportDetailName', () => { + const result = client.matchReportDetailFromReportDetailName(fakePath); + assert.strictEqual(result, 'reportDetailValue'); + assert( + (client.pathTemplates.reportDetailPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-storageinsights/webpack.config.js b/packages/google-cloud-storageinsights/webpack.config.js index 867cbb1b8f32..451be2839455 100644 --- a/packages/google-cloud-storageinsights/webpack.config.js +++ b/packages/google-cloud-storageinsights/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-support/.eslintignore b/packages/google-cloud-support/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-support/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-support/.eslintrc.json b/packages/google-cloud-support/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-support/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-support/README.md b/packages/google-cloud-support/README.md index 6ddbe43a7fb5..e4d980bf07fc 100644 --- a/packages/google-cloud-support/README.md +++ b/packages/google-cloud-support/README.md @@ -118,7 +118,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-support/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`) @@ -128,7 +128,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-support/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-support/protos/protos.d.ts b/packages/google-cloud-support/protos/protos.d.ts index bda14d751a73..302aa7038962 100644 --- a/packages/google-cloud-support/protos/protos.d.ts +++ b/packages/google-cloud-support/protos/protos.d.ts @@ -7174,6 +7174,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -7191,6 +7194,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 @@ -7891,6 +7897,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -7905,6 +7914,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 @@ -7983,6 +7995,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 { @@ -8309,6 +8433,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -8323,6 +8450,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 @@ -8647,6 +8777,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, @@ -8763,6 +8996,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -8793,6 +9027,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -8842,6 +9079,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -8976,6 +9216,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -9017,6 +9260,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 @@ -9864,6 +10110,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -9890,6 +10139,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 @@ -10824,6 +11076,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); @@ -10879,6 +11134,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[]; @@ -11099,6 +11357,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. */ @@ -11337,6 +11710,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -11359,6 +11735,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[]; @@ -11948,6 +12327,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. */ @@ -11977,6 +12362,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 @@ -12099,6 +12490,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. */ @@ -12218,8 +12719,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. */ @@ -12234,8 +12738,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. @@ -12768,6 +13275,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-support/protos/protos.js b/packages/google-cloud-support/protos/protos.js index 54c87cf8b68e..b3c4ea8194ac 100644 --- a/packages/google-cloud-support/protos/protos.js +++ b/packages/google-cloud-support/protos/protos.js @@ -17171,6 +17171,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -17205,6 +17206,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 @@ -17237,6 +17246,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; }; @@ -17288,6 +17299,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; @@ -17339,6 +17354,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; }; @@ -17381,6 +17401,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; }; @@ -17399,8 +17424,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) { @@ -17408,6 +17435,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; }; @@ -19230,6 +19259,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -19255,6 +19285,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 @@ -19281,6 +19319,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; }; @@ -19321,6 +19361,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; @@ -19361,6 +19405,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; }; @@ -19381,6 +19430,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; }; @@ -19397,10 +19451,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; }; @@ -19430,6 +19488,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; })(); @@ -20306,6 +20616,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -20317,6 +20628,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) @@ -20331,6 +20643,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 @@ -20357,6 +20677,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; }; @@ -20387,7 +20710,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) @@ -20397,6 +20720,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; @@ -20437,6 +20783,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; }; @@ -20457,6 +20811,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; }; @@ -20473,10 +20834,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; }; @@ -21115,30 +21484,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; @@ -21384,6 +21998,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 @@ -21398,6 +22013,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; @@ -21422,6 +22038,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 @@ -21444,6 +22061,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -21494,6 +22112,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 @@ -21615,6 +22241,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; }; @@ -21687,6 +22316,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 = []; @@ -21789,6 +22424,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"; @@ -21843,6 +22485,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -21895,6 +22538,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"); @@ -21958,6 +22608,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -22023,6 +22677,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -22079,6 +22734,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; }; @@ -22127,6 +22787,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 */ /** @@ -22232,6 +22893,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 @@ -22284,6 +22953,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; }; @@ -22376,6 +23047,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -22489,6 +23164,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; }; @@ -22588,6 +23272,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; }; @@ -22617,6 +23321,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; @@ -22662,6 +23367,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; }; @@ -24706,6 +25413,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 */ /** @@ -24766,6 +25474,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 @@ -24803,6 +25519,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; }; @@ -24865,6 +25583,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -24933,6 +25655,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; }; @@ -24982,6 +25713,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; }; @@ -25006,6 +25757,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; @@ -25026,6 +25778,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; }; @@ -27344,6 +28098,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 @@ -27464,6 +28219,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 @@ -27538,6 +28301,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(); @@ -27639,6 +28404,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 = []; @@ -27774,6 +28543,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"; @@ -27962,6 +28736,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"); @@ -28059,6 +28838,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")) @@ -28091,6 +28871,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) @@ -28363,6 +29145,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -28404,103 +29187,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; @@ -29095,6 +30364,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 */ @@ -29138,6 +30408,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 @@ -29176,6 +30454,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(); @@ -29227,6 +30507,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 = []; @@ -29279,6 +30563,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"; @@ -29312,6 +30601,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"); @@ -29344,6 +30638,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -29351,6 +30646,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) @@ -30790,6 +32087,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 */ /** @@ -30855,6 +32154,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 @@ -30891,6 +32206,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; }; @@ -30951,6 +32270,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; @@ -31041,6 +32368,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; }; @@ -31180,6 +32527,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; }; @@ -31203,6 +32598,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; @@ -31216,6 +32613,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; }; @@ -31343,6 +32744,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; })(); @@ -31527,6 +33141,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31544,6 +33159,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31592,6 +33208,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -31644,6 +33264,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -31752,7 +33376,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 */ /** @@ -31779,12 +33404,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. @@ -31810,10 +33443,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; }; @@ -31854,8 +33489,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: @@ -31898,6 +33537,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -31910,10 +33550,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; }; @@ -31941,6 +33586,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -31982,10 +33631,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; }; @@ -32004,13 +33658,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; }; @@ -33225,6 +34882,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-support/protos/protos.json b/packages/google-cloud-support/protos/protos.json index 461f1eefc45d..eed9e098d04d 100644 --- a/packages/google-cloud-support/protos/protos.json +++ b/packages/google-cloud-support/protos/protos.json @@ -1904,8 +1904,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": { @@ -2128,6 +2127,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -2268,6 +2271,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 + } + } } } }, @@ -2325,6 +2350,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -2386,6 +2416,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -2419,12 +2462,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, @@ -2463,6 +2513,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -2551,6 +2606,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -2776,6 +2835,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -2826,7 +2889,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -2990,6 +3060,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -3125,7 +3196,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -3153,6 +3225,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3222,6 +3298,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 + } + } } } }, @@ -3310,6 +3406,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -3452,6 +3552,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -3462,6 +3563,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -3472,6 +3574,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -3482,6 +3585,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -3492,7 +3596,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" } }, @@ -3502,27 +3607,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, @@ -3567,7 +3683,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -3582,6 +3704,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 + } + } + } } } }, @@ -3609,11 +3758,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -3626,6 +3790,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -3711,6 +3881,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { diff --git a/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json b/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json index f6dec4abe7bc..fa991325c322 100644 --- a/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json +++ b/packages/google-cloud-support/samples/generated/v2/snippet_metadata_google.cloud.support.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-support", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json b/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json index 682beecf210c..b1a161618568 100644 --- a/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json +++ b/packages/google-cloud-support/samples/generated/v2beta/snippet_metadata_google.cloud.support.v2beta.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-support", - "version": "2.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-support/src/v2/case_attachment_service_client.ts b/packages/google-cloud-support/src/v2/case_attachment_service_client.ts index e1ed9634d722..684c34c63440 100644 --- a/packages/google-cloud-support/src/v2/case_attachment_service_client.ts +++ b/packages/google-cloud-support/src/v2/case_attachment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CaseAttachmentServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CaseAttachmentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseAttachmentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseAttachmentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseAttachmentServiceClient. @@ -100,21 +107,43 @@ export class CaseAttachmentServiceClient { * const client = new CaseAttachmentServiceClient({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 CaseAttachmentServiceClient; - 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 CaseAttachmentServiceClient; + 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 = 'cloudsupport.' + 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; @@ -139,7 +168,7 @@ export class CaseAttachmentServiceClient { 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; @@ -153,10 +182,7 @@ export class CaseAttachmentServiceClient { } // 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 { @@ -178,22 +204,23 @@ export class CaseAttachmentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -201,14 +228,20 @@ export class CaseAttachmentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAttachments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attachments') + listAttachments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'attachments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CaseAttachmentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CaseAttachmentService', + 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 @@ -239,37 +272,40 @@ export class CaseAttachmentServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CaseAttachmentService. this.caseAttachmentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CaseAttachmentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CaseAttachmentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CaseAttachmentService, - 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 caseAttachmentServiceStubMethods = - ['listAttachments']; + const caseAttachmentServiceStubMethods = ['listAttachments']; for (const methodName of caseAttachmentServiceStubMethods) { const callPromise = this.caseAttachmentServiceStub.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; @@ -284,8 +320,14 @@ export class CaseAttachmentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -296,8 +338,14 @@ export class CaseAttachmentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -328,9 +376,7 @@ export class CaseAttachmentServiceClient { * @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; @@ -339,8 +385,9 @@ export class CaseAttachmentServiceClient { * 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; @@ -352,95 +399,120 @@ export class CaseAttachmentServiceClient { // -- Service calls -- // ------------------- - /** - * List all the attachments associated with a support case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Attachment|Attachment}. - * 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 `listAttachmentsAsync()` - * method described below for async iteration which you can stop as 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 all the attachments associated with a support case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Attachment|Attachment}. + * 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 `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachments( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]>; + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ] + >; listAttachments( - request: protos.google.cloud.support.v2.IListAttachmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): void; + request: protos.google.cloud.support.v2.IListAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): void; listAttachments( - request: protos.google.cloud.support.v2.IListAttachmentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): void; + request: protos.google.cloud.support.v2.IListAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): void; listAttachments( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>): - Promise<[ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]>|void { + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + >, + ): Promise< + [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2.IListAttachmentsRequest, - protos.google.cloud.support.v2.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2.IAttachment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListAttachmentsRequest, + | protos.google.cloud.support.v2.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IAttachment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAttachments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -449,122 +521,126 @@ export class CaseAttachmentServiceClient { this._log.info('listAttachments request %j', request); return this.innerApiCalls .listAttachments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.IAttachment[], - protos.google.cloud.support.v2.IListAttachmentsRequest|null, - protos.google.cloud.support.v2.IListAttachmentsResponse - ]) => { - this._log.info('listAttachments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.IAttachment[], + protos.google.cloud.support.v2.IListAttachmentsRequest | null, + protos.google.cloud.support.v2.IListAttachmentsResponse, + ]) => { + this._log.info('listAttachments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAttachments`, 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 case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Attachment|Attachment} 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 `listAttachmentsAsync()` - * method described below for async iteration which you can stop as 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 `listAttachments`, 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 case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Attachment|Attachment} 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 `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachmentsStream( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + 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['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments stream %j', request); return this.descriptors.page.listAttachments.createStream( this.innerApiCalls.listAttachments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAttachments`, 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 case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Attachment|Attachment}. 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/case_attachment_service.list_attachments.js - * region_tag:cloudsupport_v2_generated_CaseAttachmentService_ListAttachments_async - */ + /** + * Equivalent to `listAttachments`, 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 case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Attachment|Attachment}. 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/case_attachment_service.list_attachments.js + * region_tag:cloudsupport_v2_generated_CaseAttachmentService_ListAttachments_async + */ listAttachmentsAsync( - request?: protos.google.cloud.support.v2.IListAttachmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListAttachmentsRequest, + 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['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments iterate %j', request); return this.descriptors.page.listAttachments.asyncIterate( this.innerApiCalls['listAttachments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -578,7 +654,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -593,7 +669,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -604,7 +682,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -615,7 +695,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -630,8 +714,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -641,8 +729,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -652,8 +744,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -664,7 +760,11 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -679,8 +779,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -690,8 +794,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -701,8 +809,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -712,7 +824,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -727,7 +839,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -738,7 +851,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -749,7 +863,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -764,8 +882,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -775,8 +897,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -786,8 +912,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -798,7 +928,7 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -814,7 +944,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -825,7 +957,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -836,7 +970,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -847,7 +983,7 @@ export class CaseAttachmentServiceClient { */ close(): Promise { if (this.caseAttachmentServiceStub && !this._terminated) { - return this.caseAttachmentServiceStub.then(stub => { + return this.caseAttachmentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -855,4 +991,4 @@ export class CaseAttachmentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/case_service_client.ts b/packages/google-cloud-support/src/v2/case_service_client.ts index 2906526ea18e..69e926b7dfc9 100644 --- a/packages/google-cloud-support/src/v2/case_service_client.ts +++ b/packages/google-cloud-support/src/v2/case_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CaseServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CaseServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseServiceClient. @@ -100,21 +107,42 @@ export class CaseServiceClient { * const client = new CaseServiceClient({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 CaseServiceClient; - 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 = 'cloudsupport.' + 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; @@ -139,7 +167,7 @@ export class CaseServiceClient { 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; @@ -153,10 +181,7 @@ export class CaseServiceClient { } // 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 { @@ -178,25 +203,26 @@ export class CaseServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' + 'organizations/{organization}', ), organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -204,18 +230,30 @@ export class CaseServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCaseClassifications: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'caseClassifications') + listCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCaseClassifications: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'caseClassifications', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CaseService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CaseService', + 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 @@ -246,37 +284,49 @@ export class CaseServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CaseService. this.caseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CaseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CaseService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CaseService, - 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 caseServiceStubMethods = - ['getCase', 'listCases', 'searchCases', 'createCase', 'updateCase', 'escalateCase', 'closeCase', 'searchCaseClassifications']; + const caseServiceStubMethods = [ + 'getCase', + 'listCases', + 'searchCases', + 'createCase', + 'updateCase', + 'escalateCase', + 'closeCase', + 'searchCaseClassifications', + ]; for (const methodName of caseServiceStubMethods) { const callPromise = this.caseServiceStub.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; @@ -291,8 +341,14 @@ export class CaseServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -303,8 +359,14 @@ export class CaseServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -335,9 +397,7 @@ export class CaseServiceClient { * @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; @@ -346,8 +406,9 @@ export class CaseServiceClient { * 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; @@ -358,606 +419,775 @@ export class CaseServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of a case to be retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@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/case_service.get_case.js - * region_tag:cloudsupport_v2_generated_CaseService_GetCase_async - */ + /** + * Retrieve a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of a case to be retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@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/case_service.get_case.js + * region_tag:cloudsupport_v2_generated_CaseService_GetCase_async + */ getCase( - request?: protos.google.cloud.support.v2.IGetCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IGetCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ] + >; getCase( - request: protos.google.cloud.support.v2.IGetCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IGetCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request: protos.google.cloud.support.v2.IGetCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IGetCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request?: protos.google.cloud.support.v2.IGetCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.IGetCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IGetCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IGetCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Create a new case and associate it with a parent. - * - * It must have the following fields set: `display_name`, `description`, - * `classification`, and `priority`. If you're just testing the API and don't - * want to route your case to an agent, set `testCase=true`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent under which the case should be created. - * @param {google.cloud.support.v2.Case} request.case - * Required. The case 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 {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@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/case_service.create_case.js - * region_tag:cloudsupport_v2_generated_CaseService_CreateCase_async - */ + /** + * Create a new case and associate it with a parent. + * + * It must have the following fields set: `display_name`, `description`, + * `classification`, and `priority`. If you're just testing the API and don't + * want to route your case to an agent, set `testCase=true`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent under which the case should be created. + * @param {google.cloud.support.v2.Case} request.case + * Required. The case 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 {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@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/case_service.create_case.js + * region_tag:cloudsupport_v2_generated_CaseService_CreateCase_async + */ createCase( - request?: protos.google.cloud.support.v2.ICreateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICreateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ] + >; createCase( - request: protos.google.cloud.support.v2.ICreateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request: protos.google.cloud.support.v2.ICreateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request?: protos.google.cloud.support.v2.ICreateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.ICreateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICreateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICreateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a case. Only some fields can be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.support.v2.Case} request.case - * Required. The case to update. - * @param {google.protobuf.FieldMask} request.updateMask - * A list of attributes of the case that should be updated. Supported values - * are `priority`, `display_name`, and `subscriber_email_addresses`. If no - * fields are specified, all supported fields are updated. - * - * Be careful - if you do not provide a field mask, then you might - * accidentally clear some fields. For example, if you leave the field mask - * empty and do not provide a value for `subscriber_email_addresses`, then - * `subscriber_email_addresses` is updated to empty. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@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/case_service.update_case.js - * region_tag:cloudsupport_v2_generated_CaseService_UpdateCase_async - */ + /** + * Update a case. Only some fields can be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.support.v2.Case} request.case + * Required. The case to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A list of attributes of the case that should be updated. Supported values + * are `priority`, `display_name`, and `subscriber_email_addresses`. If no + * fields are specified, all supported fields are updated. + * + * Be careful - if you do not provide a field mask, then you might + * accidentally clear some fields. For example, if you leave the field mask + * empty and do not provide a value for `subscriber_email_addresses`, then + * `subscriber_email_addresses` is updated to empty. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@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/case_service.update_case.js + * region_tag:cloudsupport_v2_generated_CaseService_UpdateCase_async + */ updateCase( - request?: protos.google.cloud.support.v2.IUpdateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IUpdateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ] + >; updateCase( - request: protos.google.cloud.support.v2.IUpdateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IUpdateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request: protos.google.cloud.support.v2.IUpdateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IUpdateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request?: protos.google.cloud.support.v2.IUpdateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2.IUpdateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'case.name': request.case!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'case.name': request.case!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IUpdateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IUpdateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Escalate a case, starting the Google Cloud Support escalation management - * process. - * - * This operation is only available for some support services. Go to - * https://cloud.google.com/support and look for 'Technical support - * escalations' in the feature list to find out which ones let you - * do that. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to be escalated. - * @param {google.cloud.support.v2.Escalation} request.escalation - * The escalation information to be sent with the escalation 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 an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@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/case_service.escalate_case.js - * region_tag:cloudsupport_v2_generated_CaseService_EscalateCase_async - */ + /** + * Escalate a case, starting the Google Cloud Support escalation management + * process. + * + * This operation is only available for some support services. Go to + * https://cloud.google.com/support and look for 'Technical support + * escalations' in the feature list to find out which ones let you + * do that. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to be escalated. + * @param {google.cloud.support.v2.Escalation} request.escalation + * The escalation information to be sent with the escalation 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 an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@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/case_service.escalate_case.js + * region_tag:cloudsupport_v2_generated_CaseService_EscalateCase_async + */ escalateCase( - request?: protos.google.cloud.support.v2.IEscalateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.IEscalateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ] + >; escalateCase( - request: protos.google.cloud.support.v2.IEscalateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IEscalateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request: protos.google.cloud.support.v2.IEscalateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.IEscalateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request?: protos.google.cloud.support.v2.IEscalateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.IEscalateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('escalateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + | protos.google.cloud.support.v2.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('escalateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.escalateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.IEscalateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('escalateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .escalateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.IEscalateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('escalateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Close a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to close. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. - * Please see the {@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/case_service.close_case.js - * region_tag:cloudsupport_v2_generated_CaseService_CloseCase_async - */ + /** + * Close a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to close. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Case|Case}. + * Please see the {@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/case_service.close_case.js + * region_tag:cloudsupport_v2_generated_CaseService_CloseCase_async + */ closeCase( - request?: protos.google.cloud.support.v2.ICloseCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICloseCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ] + >; closeCase( - request: protos.google.cloud.support.v2.ICloseCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICloseCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request: protos.google.cloud.support.v2.ICloseCaseRequest, - callback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICloseCaseRequest, + callback: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request?: protos.google.cloud.support.v2.ICloseCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2.ICloseCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('closeCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('closeCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.closeCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.ICase, - protos.google.cloud.support.v2.ICloseCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('closeCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .closeCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.ICase, + protos.google.cloud.support.v2.ICloseCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('closeCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * Retrieve all cases under a parent, but not its children. - * - * For example, listing cases under an organization only returns the cases - * that are directly parented by that organization. To retrieve cases - * under an organization and its projects, use `cases.search`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Case|Case}. - * 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 `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve all cases under a parent, but not its children. + * + * For example, listing cases under an organization only returns the cases + * that are directly parented by that organization. To retrieve cases + * under an organization and its projects, use `cases.search`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Case|Case}. + * 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 `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCases( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]>; + request?: protos.google.cloud.support.v2.IListCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ] + >; listCases( - request: protos.google.cloud.support.v2.IListCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.IListCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; listCases( - request: protos.google.cloud.support.v2.IListCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.IListCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; listCases( - request?: protos.google.cloud.support.v2.IListCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]>|void { + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2.IListCasesRequest, - protos.google.cloud.support.v2.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListCasesRequest, + protos.google.cloud.support.v2.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -966,266 +1196,289 @@ export class CaseServiceClient { this._log.info('listCases request %j', request); return this.innerApiCalls .listCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.IListCasesRequest|null, - protos.google.cloud.support.v2.IListCasesResponse - ]) => { - this._log.info('listCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.IListCasesRequest | null, + protos.google.cloud.support.v2.IListCasesResponse, + ]) => { + this._log.info('listCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Case|Case} 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 `listCasesAsync()` - * method described below for async iteration which you can stop as 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 `listCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Case|Case} 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 `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCasesStream( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListCasesRequest, + 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['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases stream %j', request); return this.descriptors.page.listCases.createStream( this.innerApiCalls.listCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCases`, 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 a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Case|Case}. 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/case_service.list_cases.js - * region_tag:cloudsupport_v2_generated_CaseService_ListCases_async - */ + /** + * Equivalent to `listCases`, 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 a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Case|Case}. 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/case_service.list_cases.js + * region_tag:cloudsupport_v2_generated_CaseService_ListCases_async + */ listCasesAsync( - request?: protos.google.cloud.support.v2.IListCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListCasesRequest, + 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['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases iterate %j', request); return this.descriptors.page.listCases.asyncIterate( this.innerApiCalls['listCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Search for cases using a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Case|Case}. - * 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 `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Search for cases using a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.Case|Case}. + * 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 `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCases( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]>; + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ] + >; searchCases( - request: protos.google.cloud.support.v2.ISearchCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.ISearchCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; searchCases( - request: protos.google.cloud.support.v2.ISearchCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): void; + request: protos.google.cloud.support.v2.ISearchCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): void; searchCases( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>): - Promise<[ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]>|void { + | protos.google.cloud.support.v2.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + protos.google.cloud.support.v2.ISearchCasesResponse | null | undefined, + protos.google.cloud.support.v2.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2.ISearchCasesRequest, - protos.google.cloud.support.v2.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.ISearchCasesRequest, + | protos.google.cloud.support.v2.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1234,267 +1487,297 @@ export class CaseServiceClient { this._log.info('searchCases request %j', request); return this.innerApiCalls .searchCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICase[], - protos.google.cloud.support.v2.ISearchCasesRequest|null, - protos.google.cloud.support.v2.ISearchCasesResponse - ]) => { - this._log.info('searchCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICase[], + protos.google.cloud.support.v2.ISearchCasesRequest | null, + protos.google.cloud.support.v2.ISearchCasesResponse, + ]) => { + this._log.info('searchCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Case|Case} 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 `searchCasesAsync()` - * method described below for async iteration which you can stop as 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 `searchCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Case|Case} 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 `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCasesStream( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + 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['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases stream %j', request); return this.descriptors.page.searchCases.createStream( this.innerApiCalls.searchCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCases`, 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 - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.Case|Case}. 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/case_service.search_cases.js - * region_tag:cloudsupport_v2_generated_CaseService_SearchCases_async - */ + /** + * Equivalent to `searchCases`, 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 + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.Case|Case}. 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/case_service.search_cases.js + * region_tag:cloudsupport_v2_generated_CaseService_SearchCases_async + */ searchCasesAsync( - request?: protos.google.cloud.support.v2.ISearchCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.ISearchCasesRequest, + 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['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases iterate %j', request); return this.descriptors.page.searchCases.asyncIterate( this.innerApiCalls['searchCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Retrieve valid classifications to use when creating a support case. - * - * Classifications are hierarchical. Each classification is a string - * containing all levels of the hierarchy separated by `" > "`. For example, - * `"Technical Issue > Compute > Compute Engine"`. - * - * Classification IDs returned by this endpoint are valid for at least six - * months. When a classification is deactivated, this endpoint immediately - * stops returning it. After six months, `case.create` requests using the - * classification will fail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.CaseClassification|CaseClassification}. - * 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 `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve valid classifications to use when creating a support case. + * + * Classifications are hierarchical. Each classification is a string + * containing all levels of the hierarchy separated by `" > "`. For example, + * `"Technical Issue > Compute > Compute Engine"`. + * + * Classification IDs returned by this endpoint are valid for at least six + * months. When a classification is deactivated, this endpoint immediately + * stops returning it. After six months, `case.create` requests using the + * classification will fail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2.CaseClassification|CaseClassification}. + * 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 `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassifications( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]>; + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ] + >; searchCaseClassifications( - request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): void; + request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): void; searchCaseClassifications( - request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): void; + request: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): void; searchCaseClassifications( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>, - callback?: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>): - Promise<[ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]>|void { + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + >, + ): Promise< + [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2.ICaseClassification>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2.ICaseClassification + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCaseClassifications values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1503,104 +1786,110 @@ export class CaseServiceClient { this._log.info('searchCaseClassifications request %j', request); return this.innerApiCalls .searchCaseClassifications(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.ICaseClassification[], - protos.google.cloud.support.v2.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2.ISearchCaseClassificationsResponse - ]) => { - this._log.info('searchCaseClassifications values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.ICaseClassification[], + protos.google.cloud.support.v2.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2.ISearchCaseClassificationsResponse, + ]) => { + this._log.info('searchCaseClassifications values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.CaseClassification|CaseClassification} 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 `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as 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 `searchCaseClassifications`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.CaseClassification|CaseClassification} 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 `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassificationsStream( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications stream %j', request); return this.descriptors.page.searchCaseClassifications.createStream( this.innerApiCalls.searchCaseClassifications as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCaseClassifications`, 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.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2.CaseClassification|CaseClassification}. 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/case_service.search_case_classifications.js - * region_tag:cloudsupport_v2_generated_CaseService_SearchCaseClassifications_async - */ + /** + * Equivalent to `searchCaseClassifications`, 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.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2.CaseClassification|CaseClassification}. 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/case_service.search_case_classifications.js + * region_tag:cloudsupport_v2_generated_CaseService_SearchCaseClassifications_async + */ searchCaseClassificationsAsync( - request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications iterate %j', request); return this.descriptors.page.searchCaseClassifications.asyncIterate( this.innerApiCalls['searchCaseClassifications'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1613,7 +1902,7 @@ export class CaseServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationPath(organization:string) { + organizationPath(organization: string) { return this.pathTemplates.organizationPathTemplate.render({ organization: organization, }); @@ -1627,7 +1916,8 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + return this.pathTemplates.organizationPathTemplate.match(organizationName) + .organization; } /** @@ -1637,7 +1927,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -1652,7 +1942,9 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -1663,7 +1955,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -1674,7 +1968,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -1689,8 +1987,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -1700,8 +2002,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -1711,8 +2017,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -1723,7 +2033,11 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -1738,8 +2052,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -1749,8 +2067,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -1760,8 +2082,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -1771,7 +2097,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -1786,7 +2112,8 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -1797,7 +2124,8 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -1808,7 +2136,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -1823,8 +2155,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1834,8 +2170,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1845,8 +2185,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1857,7 +2201,7 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1873,7 +2217,9 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1884,7 +2230,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1895,7 +2243,9 @@ export class CaseServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1906,7 +2256,7 @@ export class CaseServiceClient { */ close(): Promise { if (this.caseServiceStub && !this._terminated) { - return this.caseServiceStub.then(stub => { + return this.caseServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1914,4 +2264,4 @@ export class CaseServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/comment_service_client.ts b/packages/google-cloud-support/src/v2/comment_service_client.ts index b4c4c5842144..2aac71a17f39 100644 --- a/packages/google-cloud-support/src/v2/comment_service_client.ts +++ b/packages/google-cloud-support/src/v2/comment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CommentServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CommentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - commentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + commentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CommentServiceClient. @@ -100,21 +107,42 @@ export class CommentServiceClient { * const client = new CommentServiceClient({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 CommentServiceClient; - 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 = 'cloudsupport.' + 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; @@ -139,7 +167,7 @@ export class CommentServiceClient { 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; @@ -153,10 +181,7 @@ export class CommentServiceClient { } // 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 { @@ -178,22 +203,23 @@ export class CommentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), }; @@ -201,14 +227,20 @@ export class CommentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listComments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'comments') + listComments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'comments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2.CommentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2.CommentService', + 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 @@ -239,37 +271,40 @@ export class CommentServiceClient { // Put together the "service stub" for // google.cloud.support.v2.CommentService. this.commentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2.CommentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2.CommentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2.CommentService, - 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 commentServiceStubMethods = - ['listComments', 'createComment']; + const commentServiceStubMethods = ['listComments', 'createComment']; for (const methodName of commentServiceStubMethods) { const callPromise = this.commentServiceStub.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; @@ -284,8 +319,14 @@ export class CommentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -296,8 +337,14 @@ export class CommentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -328,9 +375,7 @@ export class CommentServiceClient { * @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; @@ -339,8 +384,9 @@ export class CommentServiceClient { * 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; @@ -351,187 +397,240 @@ export class CommentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Add a new comment to a case. - * - * The comment must have the following fields set: `body`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case to which the comment should be added. - * @param {google.cloud.support.v2.Comment} request.comment - * Required. The comment to be added. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Comment|Comment}. - * Please see the {@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/comment_service.create_comment.js - * region_tag:cloudsupport_v2_generated_CommentService_CreateComment_async - */ + /** + * Add a new comment to a case. + * + * The comment must have the following fields set: `body`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case to which the comment should be added. + * @param {google.cloud.support.v2.Comment} request.comment + * Required. The comment to be added. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2.Comment|Comment}. + * Please see the {@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/comment_service.create_comment.js + * region_tag:cloudsupport_v2_generated_CommentService_CreateComment_async + */ createComment( - request?: protos.google.cloud.support.v2.ICreateCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2.ICreateCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ] + >; createComment( - request: protos.google.cloud.support.v2.ICreateCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; createComment( - request: protos.google.cloud.support.v2.ICreateCommentRequest, - callback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2.ICreateCommentRequest, + callback: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; createComment( - request?: protos.google.cloud.support.v2.ICreateCommentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2.ICreateCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2.IComment, + | protos.google.cloud.support.v2.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2.IComment, - protos.google.cloud.support.v2.ICreateCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('createComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2.IComment, + protos.google.cloud.support.v2.ICreateCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * List all the comments associated with a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2.Comment|Comment}. - * 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 `listCommentsAsync()` - * method described below for async iteration which you can stop as 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 all the comments associated with a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2.Comment|Comment}. + * 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 `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listComments( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]>; + request?: protos.google.cloud.support.v2.IListCommentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ] + >; listComments( - request: protos.google.cloud.support.v2.IListCommentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): void; + request: protos.google.cloud.support.v2.IListCommentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): void; listComments( - request: protos.google.cloud.support.v2.IListCommentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): void; + request: protos.google.cloud.support.v2.IListCommentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): void; listComments( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2.IListCommentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>): - Promise<[ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]>|void { + | protos.google.cloud.support.v2.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IComment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + protos.google.cloud.support.v2.IListCommentsResponse | null | undefined, + protos.google.cloud.support.v2.IComment + >, + ): Promise< + [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2.IListCommentsRequest, - protos.google.cloud.support.v2.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2.IComment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2.IListCommentsRequest, + | protos.google.cloud.support.v2.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2.IComment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listComments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -540,108 +639,112 @@ export class CommentServiceClient { this._log.info('listComments request %j', request); return this.innerApiCalls .listComments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2.IComment[], - protos.google.cloud.support.v2.IListCommentsRequest|null, - protos.google.cloud.support.v2.IListCommentsResponse - ]) => { - this._log.info('listComments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2.IComment[], + protos.google.cloud.support.v2.IListCommentsRequest | null, + protos.google.cloud.support.v2.IListCommentsResponse, + ]) => { + this._log.info('listComments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listComments`, 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 case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2.Comment|Comment} 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 `listCommentsAsync()` - * method described below for async iteration which you can stop as 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 `listComments`, 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 case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2.Comment|Comment} 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 `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCommentsStream( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2.IListCommentsRequest, + 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['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments stream %j', request); return this.descriptors.page.listComments.createStream( this.innerApiCalls.listComments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listComments`, 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 case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2.Comment|Comment}. 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/comment_service.list_comments.js - * region_tag:cloudsupport_v2_generated_CommentService_ListComments_async - */ + /** + * Equivalent to `listComments`, 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 case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2.Comment|Comment}. 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/comment_service.list_comments.js + * region_tag:cloudsupport_v2_generated_CommentService_ListComments_async + */ listCommentsAsync( - request?: protos.google.cloud.support.v2.IListCommentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2.IListCommentsRequest, + 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['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments iterate %j', request); return this.descriptors.page.listComments.asyncIterate( this.innerApiCalls['listComments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -655,7 +758,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -670,7 +773,9 @@ export class CommentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -681,7 +786,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -692,7 +799,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -707,8 +818,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -718,8 +833,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -729,8 +848,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -741,7 +864,11 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -756,8 +883,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -767,8 +898,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -778,8 +913,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -789,7 +928,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -804,7 +943,8 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -815,7 +955,8 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -826,7 +967,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -841,8 +986,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -852,8 +1001,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -863,8 +1016,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -875,7 +1032,7 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -891,7 +1048,9 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -902,7 +1061,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -913,7 +1074,9 @@ export class CommentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -924,7 +1087,7 @@ export class CommentServiceClient { */ close(): Promise { if (this.commentServiceStub && !this._terminated) { - return this.commentServiceStub.then(stub => { + return this.commentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -932,4 +1095,4 @@ export class CommentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2/index.ts b/packages/google-cloud-support/src/v2/index.ts index adc3d2e7e29f..20adebd968ff 100644 --- a/packages/google-cloud-support/src/v2/index.ts +++ b/packages/google-cloud-support/src/v2/index.ts @@ -16,6 +16,6 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CaseAttachmentServiceClient} from './case_attachment_service_client'; -export {CaseServiceClient} from './case_service_client'; -export {CommentServiceClient} from './comment_service_client'; +export { CaseAttachmentServiceClient } from './case_attachment_service_client'; +export { CaseServiceClient } from './case_service_client'; +export { CommentServiceClient } from './comment_service_client'; diff --git a/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts b/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts index c26d85e72bcd..5dfa564cd187 100644 --- a/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/case_attachment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CaseAttachmentServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CaseAttachmentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseAttachmentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseAttachmentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseAttachmentServiceClient. @@ -100,21 +107,43 @@ export class CaseAttachmentServiceClient { * const client = new CaseAttachmentServiceClient({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 CaseAttachmentServiceClient; - 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 CaseAttachmentServiceClient; + 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 = 'cloudsupport.' + 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; @@ -139,7 +168,7 @@ export class CaseAttachmentServiceClient { 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; @@ -153,10 +182,7 @@ export class CaseAttachmentServiceClient { } // 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 { @@ -178,28 +204,30 @@ export class CaseAttachmentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +235,20 @@ export class CaseAttachmentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAttachments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'attachments') + listAttachments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'attachments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CaseAttachmentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CaseAttachmentService', + 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 +279,44 @@ export class CaseAttachmentServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CaseAttachmentService. this.caseAttachmentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CaseAttachmentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.support.v2beta.CaseAttachmentService, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CaseAttachmentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.support.v2beta + .CaseAttachmentService, + 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 caseAttachmentServiceStubMethods = - ['listAttachments', 'getAttachment']; + const caseAttachmentServiceStubMethods = [ + 'listAttachments', + 'getAttachment', + ]; for (const methodName of caseAttachmentServiceStubMethods) { const callPromise = this.caseAttachmentServiceStub.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 +331,14 @@ export class CaseAttachmentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -302,8 +349,14 @@ export class CaseAttachmentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -334,9 +387,7 @@ export class CaseAttachmentServiceClient { * @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 +396,9 @@ export class CaseAttachmentServiceClient { * 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,190 +409,255 @@ export class CaseAttachmentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve an attachment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the attachment 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.support.v2beta.Attachment|Attachment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_attachment_service.get_attachment.js - * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_GetAttachment_async - */ + /** + * Retrieve an attachment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the attachment 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.support.v2beta.Attachment|Attachment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_attachment_service.get_attachment.js + * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_GetAttachment_async + */ getAttachment( - request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ] + >; getAttachment( - request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachment( - request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; getAttachment( - request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetAttachmentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getAttachment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IAttachment, + | protos.google.cloud.support.v2beta.IGetAttachmentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getAttachment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getAttachment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IAttachment, - protos.google.cloud.support.v2beta.IGetAttachmentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getAttachment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getAttachment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IAttachment, + protos.google.cloud.support.v2beta.IGetAttachmentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getAttachment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * List all the attachments associated with a support case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.Attachment|Attachment}. - * 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 `listAttachmentsAsync()` - * method described below for async iteration which you can stop as 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 all the attachments associated with a support case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.Attachment|Attachment}. + * 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 `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachments( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ] + >; listAttachments( - request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): void; + request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): void; listAttachments( - request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): void; + request: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): void; listAttachments( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>): - Promise<[ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2beta.IListAttachmentsRequest, - protos.google.cloud.support.v2beta.IListAttachmentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IAttachment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListAttachmentsRequest, + | protos.google.cloud.support.v2beta.IListAttachmentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IAttachment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listAttachments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -549,122 +666,126 @@ export class CaseAttachmentServiceClient { this._log.info('listAttachments request %j', request); return this.innerApiCalls .listAttachments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IAttachment[], - protos.google.cloud.support.v2beta.IListAttachmentsRequest|null, - protos.google.cloud.support.v2beta.IListAttachmentsResponse - ]) => { - this._log.info('listAttachments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IAttachment[], + protos.google.cloud.support.v2beta.IListAttachmentsRequest | null, + protos.google.cloud.support.v2beta.IListAttachmentsResponse, + ]) => { + this._log.info('listAttachments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listAttachments`, 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 case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2beta.Attachment|Attachment} 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 `listAttachmentsAsync()` - * method described below for async iteration which you can stop as 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 `listAttachments`, 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 case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2beta.Attachment|Attachment} 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 `listAttachmentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listAttachmentsStream( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + 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['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments stream %j', request); return this.descriptors.page.listAttachments.createStream( this.innerApiCalls.listAttachments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listAttachments`, 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 case for which attachments should be listed. - * @param {number} request.pageSize - * The maximum number of attachments fetched with each request. - * - * If not provided, the default is 10. The maximum page size that will be - * returned is 100. - * - * The size of each page can be smaller than the requested page size and can - * include zero. For example, you could request 100 attachments on one page, - * receive 0, and then on the next page, receive 90. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2beta.Attachment|Attachment}. 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/v2beta/case_attachment_service.list_attachments.js - * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_ListAttachments_async - */ + /** + * Equivalent to `listAttachments`, 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 case for which attachments should be listed. + * @param {number} request.pageSize + * The maximum number of attachments fetched with each request. + * + * If not provided, the default is 10. The maximum page size that will be + * returned is 100. + * + * The size of each page can be smaller than the requested page size and can + * include zero. For example, you could request 100 attachments on one page, + * receive 0, and then on the next page, receive 90. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2beta.Attachment|Attachment}. 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/v2beta/case_attachment_service.list_attachments.js + * region_tag:cloudsupport_v2beta_generated_CaseAttachmentService_ListAttachments_async + */ listAttachmentsAsync( - request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListAttachmentsRequest, + 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['listAttachments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listAttachments iterate %j', request); return this.descriptors.page.listAttachments.asyncIterate( this.innerApiCalls['listAttachments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -678,7 +799,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -693,7 +814,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -704,7 +827,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -715,7 +840,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -730,8 +859,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -741,8 +874,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -752,8 +889,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -764,7 +905,11 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -779,8 +924,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -790,8 +939,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -801,8 +954,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -813,7 +970,11 @@ export class CaseAttachmentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -828,8 +989,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -839,8 +1004,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -850,8 +1019,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -861,7 +1034,7 @@ export class CaseAttachmentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -876,7 +1049,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -887,7 +1061,8 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -898,7 +1073,11 @@ export class CaseAttachmentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -913,8 +1092,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -924,8 +1107,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -935,8 +1122,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -947,7 +1138,7 @@ export class CaseAttachmentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -963,7 +1154,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -974,7 +1167,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -985,7 +1180,9 @@ export class CaseAttachmentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -996,7 +1193,11 @@ export class CaseAttachmentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1011,8 +1212,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -1022,8 +1227,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -1033,8 +1242,12 @@ export class CaseAttachmentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -1045,7 +1258,7 @@ export class CaseAttachmentServiceClient { */ close(): Promise { if (this.caseAttachmentServiceStub && !this._terminated) { - return this.caseAttachmentServiceStub.then(stub => { + return this.caseAttachmentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1053,4 +1266,4 @@ export class CaseAttachmentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/case_service_client.ts b/packages/google-cloud-support/src/v2beta/case_service_client.ts index 7e0db96918ed..bd2ce828d186 100644 --- a/packages/google-cloud-support/src/v2beta/case_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/case_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CaseServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CaseServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - caseServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + caseServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CaseServiceClient. @@ -100,21 +107,42 @@ export class CaseServiceClient { * const client = new CaseServiceClient({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 CaseServiceClient; - 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 = 'cloudsupport.' + 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; @@ -139,7 +167,7 @@ export class CaseServiceClient { 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; @@ -153,10 +181,7 @@ export class CaseServiceClient { } // 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 { @@ -178,31 +203,33 @@ export class CaseServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}' + 'organizations/{organization}', ), organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -210,18 +237,30 @@ export class CaseServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCases: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'cases'), - searchCaseClassifications: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'caseClassifications') + listCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCases: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'cases', + ), + searchCaseClassifications: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'caseClassifications', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CaseService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CaseService', + 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,37 +291,49 @@ export class CaseServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CaseService. this.caseServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CaseService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CaseService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.CaseService, - 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 caseServiceStubMethods = - ['getCase', 'listCases', 'searchCases', 'createCase', 'updateCase', 'escalateCase', 'closeCase', 'searchCaseClassifications']; + const caseServiceStubMethods = [ + 'getCase', + 'listCases', + 'searchCases', + 'createCase', + 'updateCase', + 'escalateCase', + 'closeCase', + 'searchCaseClassifications', + ]; for (const methodName of caseServiceStubMethods) { const callPromise = this.caseServiceStub.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; @@ -297,8 +348,14 @@ export class CaseServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -309,8 +366,14 @@ export class CaseServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -341,9 +404,7 @@ export class CaseServiceClient { * @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; @@ -352,8 +413,9 @@ export class CaseServiceClient { * 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; @@ -364,609 +426,800 @@ export class CaseServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Retrieve a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The full name of a case to be retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.get_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_GetCase_async - */ + /** + * Retrieve a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The full name of a case to be retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.get_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_GetCase_async + */ getCase( - request?: protos.google.cloud.support.v2beta.IGetCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ] + >; getCase( - request: protos.google.cloud.support.v2beta.IGetCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request: protos.google.cloud.support.v2beta.IGetCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; getCase( - request?: protos.google.cloud.support.v2beta.IGetCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IGetCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IGetCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Create a new case and associate it with a parent. - * - * It must have the following fields set: `display_name`, `description`, - * `classification`, and `priority`. If you're just testing the API and don't - * want to route your case to an agent, set `testCase=true`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the parent under which the case should be created. - * @param {google.cloud.support.v2beta.Case} request.case - * Required. The case 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 {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.create_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_CreateCase_async - */ + /** + * Create a new case and associate it with a parent. + * + * It must have the following fields set: `display_name`, `description`, + * `classification`, and `priority`. If you're just testing the API and don't + * want to route your case to an agent, set `testCase=true`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the parent under which the case should be created. + * @param {google.cloud.support.v2beta.Case} request.case + * Required. The case 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 {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.create_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_CreateCase_async + */ createCase( - request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ] + >; createCase( - request: protos.google.cloud.support.v2beta.ICreateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request: protos.google.cloud.support.v2beta.ICreateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; createCase( - request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.ICreateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICreateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.ICreateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICreateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICreateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update a case. Only some fields can be updated. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.support.v2beta.Case} request.case - * Required. The case to update. - * @param {google.protobuf.FieldMask} request.updateMask - * A list of attributes of the case that should be updated. Supported values - * are `priority`, `display_name`, and `subscriber_email_addresses`. If no - * fields are specified, all supported fields are updated. - * - * Be careful - if you do not provide a field mask, then you might - * accidentally clear some fields. For example, if you leave the field mask - * empty and do not provide a value for `subscriber_email_addresses`, then - * `subscriber_email_addresses` is updated to empty. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.update_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_UpdateCase_async - */ + /** + * Update a case. Only some fields can be updated. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.support.v2beta.Case} request.case + * Required. The case to update. + * @param {google.protobuf.FieldMask} request.updateMask + * A list of attributes of the case that should be updated. Supported values + * are `priority`, `display_name`, and `subscriber_email_addresses`. If no + * fields are specified, all supported fields are updated. + * + * Be careful - if you do not provide a field mask, then you might + * accidentally clear some fields. For example, if you leave the field mask + * empty and do not provide a value for `subscriber_email_addresses`, then + * `subscriber_email_addresses` is updated to empty. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.update_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_UpdateCase_async + */ updateCase( - request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ] + >; updateCase( - request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCase( - request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.IUpdateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IUpdateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'case.name': request.case!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'case.name': request.case!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IUpdateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IUpdateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IUpdateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Escalate a case, starting the Google Cloud Support escalation management - * process. - * - * This operation is only available for some support services. Go to - * https://cloud.google.com/support and look for 'Technical support - * escalations' in the feature list to find out which ones let you - * do that. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to be escalated. - * @param {google.cloud.support.v2beta.Escalation} request.escalation - * The escalation information to be sent with the escalation 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 an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.escalate_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_EscalateCase_async - */ + /** + * Escalate a case, starting the Google Cloud Support escalation management + * process. + * + * This operation is only available for some support services. Go to + * https://cloud.google.com/support and look for 'Technical support + * escalations' in the feature list to find out which ones let you + * do that. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to be escalated. + * @param {google.cloud.support.v2beta.Escalation} request.escalation + * The escalation information to be sent with the escalation 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 an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.escalate_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_EscalateCase_async + */ escalateCase( - request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ] + >; escalateCase( - request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): void; escalateCase( - request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IEscalateCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('escalateCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.IEscalateCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('escalateCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.escalateCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.IEscalateCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('escalateCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .escalateCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.IEscalateCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('escalateCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Close a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the case to close. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/case_service.close_case.js - * region_tag:cloudsupport_v2beta_generated_CaseService_CloseCase_async - */ + /** + * Close a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the case to close. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Case|Case}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/case_service.close_case.js + * region_tag:cloudsupport_v2beta_generated_CaseService_CloseCase_async + */ closeCase( - request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ] + >; closeCase( - request: protos.google.cloud.support.v2beta.ICloseCaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICloseCaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request: protos.google.cloud.support.v2beta.ICloseCaseRequest, - callback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICloseCaseRequest, + callback: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): void; closeCase( - request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.ICloseCaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICloseCaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('closeCase request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.ICase, + | protos.google.cloud.support.v2beta.ICloseCaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('closeCase response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.closeCase(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.ICase, - protos.google.cloud.support.v2beta.ICloseCaseRequest|undefined, - {}|undefined - ]) => { - this._log.info('closeCase response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .closeCase(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.ICase, + protos.google.cloud.support.v2beta.ICloseCaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('closeCase response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * Retrieve all cases under a parent, but not its children. - * - * For example, listing cases under an organization only returns the cases - * that are directly parented by that organization. To retrieve cases - * under an organization and its projects, use `cases.search`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases 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.support.v2beta.Case|Case}. - * 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 `listCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve all cases under a parent, but not its children. + * + * For example, listing cases under an organization only returns the cases + * that are directly parented by that organization. To retrieve cases + * under an organization and its projects, use `cases.search`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases 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.support.v2beta.Case|Case}. + * 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 `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCases( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ] + >; listCases( - request: protos.google.cloud.support.v2beta.IListCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.IListCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; listCases( - request: protos.google.cloud.support.v2beta.IListCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.IListCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; listCases( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + protos.google.cloud.support.v2beta.IListCasesResponse | null | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2beta.IListCasesRequest, - protos.google.cloud.support.v2beta.IListCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListCasesRequest, + | protos.google.cloud.support.v2beta.IListCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -975,272 +1228,301 @@ export class CaseServiceClient { this._log.info('listCases request %j', request); return this.innerApiCalls .listCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.IListCasesRequest|null, - protos.google.cloud.support.v2beta.IListCasesResponse - ]) => { - this._log.info('listCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.IListCasesRequest | null, + protos.google.cloud.support.v2beta.IListCasesResponse, + ]) => { + this._log.info('listCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases 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.support.v2beta.Case|Case} 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 `listCasesAsync()` - * method described below for async iteration which you can stop as 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 `listCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases 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.support.v2beta.Case|Case} 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 `listCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCasesStream( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + 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['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases stream %j', request); return this.descriptors.page.listCases.createStream( this.innerApiCalls.listCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCases`, 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 a parent to list cases under. - * @param {string} request.filter - * An expression used to filter cases. - * - * If it's an empty string, then no filtering happens. Otherwise, the endpoint - * returns the cases that match the filter. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * EXAMPLES: - * - * - `state=CLOSED` - * - `state=OPEN AND creator.email="tester@example.com"` - * - `state=OPEN AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.ProductLine} request.productLine - * The product line to request cases for. If unspecified, only - * Google Cloud cases 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.support.v2beta.Case|Case}. 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/v2beta/case_service.list_cases.js - * region_tag:cloudsupport_v2beta_generated_CaseService_ListCases_async - */ + /** + * Equivalent to `listCases`, 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 a parent to list cases under. + * @param {string} request.filter + * An expression used to filter cases. + * + * If it's an empty string, then no filtering happens. Otherwise, the endpoint + * returns the cases that match the filter. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * EXAMPLES: + * + * - `state=CLOSED` + * - `state=OPEN AND creator.email="tester@example.com"` + * - `state=OPEN AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.ProductLine} request.productLine + * The product line to request cases for. If unspecified, only + * Google Cloud cases 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.support.v2beta.Case|Case}. 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/v2beta/case_service.list_cases.js + * region_tag:cloudsupport_v2beta_generated_CaseService_ListCases_async + */ listCasesAsync( - request?: protos.google.cloud.support.v2beta.IListCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListCasesRequest, + 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['listCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCases iterate %j', request); return this.descriptors.page.listCases.asyncIterate( this.innerApiCalls['listCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Search for cases using a query. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.Case|Case}. - * 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 `searchCasesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Search for cases using a query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.Case|Case}. + * 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 `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCases( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]>; + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ] + >; searchCases( - request: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.ISearchCasesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; searchCases( - request: protos.google.cloud.support.v2beta.ISearchCasesRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): void; + request: protos.google.cloud.support.v2beta.ISearchCasesRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): void; searchCases( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>): - Promise<[ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]>|void { + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2beta.ISearchCasesRequest, - protos.google.cloud.support.v2beta.ISearchCasesResponse|null|undefined, - protos.google.cloud.support.v2beta.ICase>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCasesRequest, + | protos.google.cloud.support.v2beta.ISearchCasesResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICase + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCases values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1249,269 +1531,299 @@ export class CaseServiceClient { this._log.info('searchCases request %j', request); return this.innerApiCalls .searchCases(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICase[], - protos.google.cloud.support.v2beta.ISearchCasesRequest|null, - protos.google.cloud.support.v2beta.ISearchCasesResponse - ]) => { - this._log.info('searchCases values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICase[], + protos.google.cloud.support.v2beta.ISearchCasesRequest | null, + protos.google.cloud.support.v2beta.ISearchCasesResponse, + ]) => { + this._log.info('searchCases values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCases`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2beta.Case|Case} 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 `searchCasesAsync()` - * method described below for async iteration which you can stop as 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 `searchCases`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2beta.Case|Case} 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 `searchCasesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCasesStream( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + 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['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases stream %j', request); return this.descriptors.page.searchCases.createStream( this.innerApiCalls.searchCases as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCases`, 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 - * The name of the parent resource to search for cases under. - * @param {string} request.query - * An expression used to filter cases. - * - * Expressions use the following fields separated by `AND` and specified with - * `=`: - * - * - `organization`: An organization name in the form - * `organizations/`. - * - `project`: A project name in the form `projects/`. - * - `state`: Can be `OPEN` or `CLOSED`. - * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You - * can specify multiple values for priority using the `OR` operator. For - * example, `priority=P1 OR priority=P2`. - * - `creator.email`: The email address of the case creator. - * - * You must specify either `organization` or `project`. - * - * To search across `displayName`, `description`, and comments, use a global - * restriction with no keyword or operator. For example, `"my search"`. - * - * To search only cases updated after a certain date, use `update_time` - * restricted with that particular date, time, and timezone in ISO datetime - * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. - * `update_time` only supports the greater than operator (`>`). - * - * Examples: - * - * - `organization="organizations/123456789"` - * - `project="projects/my-project-id"` - * - `project="projects/123456789"` - * - `organization="organizations/123456789" AND state=CLOSED` - * - `project="projects/my-project-id" AND creator.email="tester@example.com"` - * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` - * @param {number} request.pageSize - * The maximum number of cases fetched with each request. The default page - * size is 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @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.support.v2beta.Case|Case}. 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/v2beta/case_service.search_cases.js - * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCases_async - */ + /** + * Equivalent to `searchCases`, 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 + * The name of the parent resource to search for cases under. + * @param {string} request.query + * An expression used to filter cases. + * + * Expressions use the following fields separated by `AND` and specified with + * `=`: + * + * - `organization`: An organization name in the form + * `organizations/`. + * - `project`: A project name in the form `projects/`. + * - `state`: Can be `OPEN` or `CLOSED`. + * - `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You + * can specify multiple values for priority using the `OR` operator. For + * example, `priority=P1 OR priority=P2`. + * - `creator.email`: The email address of the case creator. + * + * You must specify either `organization` or `project`. + * + * To search across `displayName`, `description`, and comments, use a global + * restriction with no keyword or operator. For example, `"my search"`. + * + * To search only cases updated after a certain date, use `update_time` + * restricted with that particular date, time, and timezone in ISO datetime + * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. + * `update_time` only supports the greater than operator (`>`). + * + * Examples: + * + * - `organization="organizations/123456789"` + * - `project="projects/my-project-id"` + * - `project="projects/123456789"` + * - `organization="organizations/123456789" AND state=CLOSED` + * - `project="projects/my-project-id" AND creator.email="tester@example.com"` + * - `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` + * @param {number} request.pageSize + * The maximum number of cases fetched with each request. The default page + * size is 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @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.support.v2beta.Case|Case}. 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/v2beta/case_service.search_cases.js + * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCases_async + */ searchCasesAsync( - request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.ISearchCasesRequest, + 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['searchCases']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCases iterate %j', request); return this.descriptors.page.searchCases.asyncIterate( this.innerApiCalls['searchCases'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Retrieve valid classifications to use when creating a support case. - * - * Classifications are hierarchical. Each classification is a string - * containing all levels of the hierarchy separated by `" > "`. For example, - * `"Technical Issue > Compute > Compute Engine"`. - * - * Classification IDs returned by this endpoint are valid for at least six - * months. When a classification is deactivated, this endpoint immediately - * stops returning it. After six months, `case.create` requests using the - * classification will fail. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.CaseClassification|CaseClassification}. - * 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 `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Retrieve valid classifications to use when creating a support case. + * + * Classifications are hierarchical. Each classification is a string + * containing all levels of the hierarchy separated by `" > "`. For example, + * `"Technical Issue > Compute > Compute Engine"`. + * + * Classification IDs returned by this endpoint are valid for at least six + * months. When a classification is deactivated, this endpoint immediately + * stops returning it. After six months, `case.create` requests using the + * classification will fail. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.CaseClassification|CaseClassification}. + * 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 `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassifications( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]>; + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ] + >; searchCaseClassifications( - request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): void; + request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): void; searchCaseClassifications( - request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): void; + request: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): void; searchCaseClassifications( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>): - Promise<[ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]>|void { + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); - const wrappedCallback: PaginationCallback< - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse|null|undefined, - protos.google.cloud.support.v2beta.ICaseClassification>|undefined = callback + this.initialize().catch((err) => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + | protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.ICaseClassification + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('searchCaseClassifications values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -1520,108 +1832,114 @@ export class CaseServiceClient { this._log.info('searchCaseClassifications request %j', request); return this.innerApiCalls .searchCaseClassifications(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.ICaseClassification[], - protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest|null, - protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse - ]) => { - this._log.info('searchCaseClassifications values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.ICaseClassification[], + protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest | null, + protos.google.cloud.support.v2beta.ISearchCaseClassificationsResponse, + ]) => { + this._log.info('searchCaseClassifications values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `searchCaseClassifications`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @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.support.v2beta.CaseClassification|CaseClassification} 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 `searchCaseClassificationsAsync()` - * method described below for async iteration which you can stop as 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 `searchCaseClassifications`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @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.support.v2beta.CaseClassification|CaseClassification} 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 `searchCaseClassificationsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ searchCaseClassificationsStream( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): Transform { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications stream %j', request); return this.descriptors.page.searchCaseClassifications.createStream( this.innerApiCalls.searchCaseClassifications as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `searchCaseClassifications`, 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.query - * An expression used to filter case classifications. - * - * If it's an empty string, then no filtering happens. Otherwise, case - * classifications will be returned that match the filter. - * @param {number} request.pageSize - * The maximum number of classifications fetched with each request. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is retrieved. - * @param {google.cloud.support.v2beta.Product} [request.product] - * Optional. The product to return case classifications for. - * @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.support.v2beta.CaseClassification|CaseClassification}. 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/v2beta/case_service.search_case_classifications.js - * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCaseClassifications_async - */ + /** + * Equivalent to `searchCaseClassifications`, 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.query + * An expression used to filter case classifications. + * + * If it's an empty string, then no filtering happens. Otherwise, case + * classifications will be returned that match the filter. + * @param {number} request.pageSize + * The maximum number of classifications fetched with each request. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is retrieved. + * @param {google.cloud.support.v2beta.Product} [request.product] + * Optional. The product to return case classifications for. + * @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.support.v2beta.CaseClassification|CaseClassification}. 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/v2beta/case_service.search_case_classifications.js + * region_tag:cloudsupport_v2beta_generated_CaseService_SearchCaseClassifications_async + */ searchCaseClassificationsAsync( - request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.ISearchCaseClassificationsRequest, + options?: CallOptions, + ): AsyncIterable { request = request || {}; options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; const defaultCallSettings = this._defaults['searchCaseClassifications']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('searchCaseClassifications iterate %j', request); return this.descriptors.page.searchCaseClassifications.asyncIterate( this.innerApiCalls['searchCaseClassifications'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1634,7 +1952,7 @@ export class CaseServiceClient { * @param {string} organization * @returns {string} Resource name string. */ - organizationPath(organization:string) { + organizationPath(organization: string) { return this.pathTemplates.organizationPathTemplate.render({ organization: organization, }); @@ -1648,7 +1966,8 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationName(organizationName: string) { - return this.pathTemplates.organizationPathTemplate.match(organizationName).organization; + return this.pathTemplates.organizationPathTemplate.match(organizationName) + .organization; } /** @@ -1658,7 +1977,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -1673,7 +1992,9 @@ export class CaseServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -1684,7 +2005,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -1695,7 +2018,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -1710,8 +2037,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -1721,8 +2052,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -1732,8 +2067,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -1744,7 +2083,11 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -1759,8 +2102,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -1770,8 +2117,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -1781,8 +2132,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -1793,7 +2148,11 @@ export class CaseServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -1808,8 +2167,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -1819,8 +2182,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -1830,8 +2197,12 @@ export class CaseServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -1841,7 +2212,7 @@ export class CaseServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -1856,7 +2227,8 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -1867,7 +2239,8 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -1878,7 +2251,11 @@ export class CaseServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -1893,8 +2270,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1904,8 +2285,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1915,8 +2300,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1927,7 +2316,7 @@ export class CaseServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1943,7 +2332,9 @@ export class CaseServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1954,7 +2345,9 @@ export class CaseServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1965,7 +2358,9 @@ export class CaseServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1976,7 +2371,11 @@ export class CaseServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1991,8 +2390,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -2002,8 +2405,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -2013,8 +2420,12 @@ export class CaseServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -2025,7 +2436,7 @@ export class CaseServiceClient { */ close(): Promise { if (this.caseServiceStub && !this._terminated) { - return this.caseServiceStub.then(stub => { + return this.caseServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2033,4 +2444,4 @@ export class CaseServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/comment_service_client.ts b/packages/google-cloud-support/src/v2beta/comment_service_client.ts index f7c02630c2ca..72c309a57154 100644 --- a/packages/google-cloud-support/src/v2beta/comment_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/comment_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CommentServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class CommentServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - commentServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + commentServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CommentServiceClient. @@ -100,21 +107,42 @@ export class CommentServiceClient { * const client = new CommentServiceClient({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 CommentServiceClient; - 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 = 'cloudsupport.' + 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; @@ -139,7 +167,7 @@ export class CommentServiceClient { 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; @@ -153,10 +181,7 @@ export class CommentServiceClient { } // 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 { @@ -178,28 +203,30 @@ export class CommentServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +234,20 @@ export class CommentServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listComments: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'comments') + listComments: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'comments', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.CommentService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.CommentService', + 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,44 @@ export class CommentServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.CommentService. this.commentServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.CommentService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.CommentService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.CommentService, - 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 commentServiceStubMethods = - ['listComments', 'createComment', 'getComment']; + const commentServiceStubMethods = [ + 'listComments', + 'createComment', + 'getComment', + ]; for (const methodName of commentServiceStubMethods) { const callPromise = this.commentServiceStub.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 +330,14 @@ export class CommentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -302,8 +348,14 @@ export class CommentServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -334,9 +386,7 @@ export class CommentServiceClient { * @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 +395,9 @@ export class CommentServiceClient { * 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,281 +408,380 @@ export class CommentServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Add a new comment to a case. - * - * The comment must have the following fields set: `body`. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case to which the comment should be added. - * @param {google.cloud.support.v2beta.Comment} request.comment - * Required. The comment to be added. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/comment_service.create_comment.js - * region_tag:cloudsupport_v2beta_generated_CommentService_CreateComment_async - */ + /** + * Add a new comment to a case. + * + * The comment must have the following fields set: `body`. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case to which the comment should be added. + * @param {google.cloud.support.v2beta.Comment} request.comment + * Required. The comment to be added. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/comment_service.create_comment.js + * region_tag:cloudsupport_v2beta_generated_CommentService_CreateComment_async + */ createComment( - request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ] + >; createComment( - request: protos.google.cloud.support.v2beta.ICreateCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createComment( - request: protos.google.cloud.support.v2beta.ICreateCommentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.ICreateCommentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createComment( - request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.support.v2beta.ICreateCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.ICreateCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.ICreateCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('createComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.ICreateCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieve a comment. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the comment to retrieve. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta/comment_service.get_comment.js - * region_tag:cloudsupport_v2beta_generated_CommentService_GetComment_async - */ + /** + * Retrieve a comment. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the comment to retrieve. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.support.v2beta.Comment|Comment}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta/comment_service.get_comment.js + * region_tag:cloudsupport_v2beta_generated_CommentService_GetComment_async + */ getComment( - request?: protos.google.cloud.support.v2beta.IGetCommentRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.support.v2beta.IGetCommentRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ] + >; getComment( - request: protos.google.cloud.support.v2beta.IGetCommentRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCommentRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; getComment( - request: protos.google.cloud.support.v2beta.IGetCommentRequest, - callback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.support.v2beta.IGetCommentRequest, + callback: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): void; getComment( - request?: protos.google.cloud.support.v2beta.IGetCommentRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.support.v2beta.IGetCommentRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.support.v2beta.IGetCommentRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getComment request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.support.v2beta.IComment, + | protos.google.cloud.support.v2beta.IGetCommentRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getComment response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getComment(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.support.v2beta.IComment, - protos.google.cloud.support.v2beta.IGetCommentRequest|undefined, - {}|undefined - ]) => { - this._log.info('getComment response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getComment(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.support.v2beta.IComment, + protos.google.cloud.support.v2beta.IGetCommentRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getComment response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } - /** - * List all the comments associated with a case. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2beta.Comment|Comment}. - * 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 `listCommentsAsync()` - * method described below for async iteration which you can stop as 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 all the comments associated with a case. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2beta.Comment|Comment}. + * 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 `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listComments( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]>; + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ] + >; listComments( - request: protos.google.cloud.support.v2beta.IListCommentsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): void; + request: protos.google.cloud.support.v2beta.IListCommentsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): void; listComments( - request: protos.google.cloud.support.v2beta.IListCommentsRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): void; + request: protos.google.cloud.support.v2beta.IListCommentsRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): void; listComments( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>, - callback?: PaginationCallback< - protos.google.cloud.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>): - Promise<[ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]>|void { + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2beta.IListCommentsRequest, - protos.google.cloud.support.v2beta.IListCommentsResponse|null|undefined, - protos.google.cloud.support.v2beta.IComment>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IListCommentsRequest, + | protos.google.cloud.support.v2beta.IListCommentsResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IComment + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listComments values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -640,108 +790,112 @@ export class CommentServiceClient { this._log.info('listComments request %j', request); return this.innerApiCalls .listComments(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IComment[], - protos.google.cloud.support.v2beta.IListCommentsRequest|null, - protos.google.cloud.support.v2beta.IListCommentsResponse - ]) => { - this._log.info('listComments values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IComment[], + protos.google.cloud.support.v2beta.IListCommentsRequest | null, + protos.google.cloud.support.v2beta.IListCommentsResponse, + ]) => { + this._log.info('listComments values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listComments`, 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 case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2beta.Comment|Comment} 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 `listCommentsAsync()` - * method described below for async iteration which you can stop as 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 `listComments`, 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 case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2beta.Comment|Comment} 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 `listCommentsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCommentsStream( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + 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['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments stream %j', request); return this.descriptors.page.listComments.createStream( this.innerApiCalls.listComments as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listComments`, 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 case for which to list comments. - * @param {number} request.pageSize - * The maximum number of comments to fetch. Defaults to 10. - * @param {string} request.pageToken - * A token identifying the page of results to return. If unspecified, the - * first page is 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.support.v2beta.Comment|Comment}. 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/v2beta/comment_service.list_comments.js - * region_tag:cloudsupport_v2beta_generated_CommentService_ListComments_async - */ + /** + * Equivalent to `listComments`, 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 case for which to list comments. + * @param {number} request.pageSize + * The maximum number of comments to fetch. Defaults to 10. + * @param {string} request.pageToken + * A token identifying the page of results to return. If unspecified, the + * first page is 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.support.v2beta.Comment|Comment}. 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/v2beta/comment_service.list_comments.js + * region_tag:cloudsupport_v2beta_generated_CommentService_ListComments_async + */ listCommentsAsync( - request?: protos.google.cloud.support.v2beta.IListCommentsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IListCommentsRequest, + 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['listComments']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listComments iterate %j', request); return this.descriptors.page.listComments.asyncIterate( this.innerApiCalls['listComments'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -755,7 +909,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -770,7 +924,9 @@ export class CommentServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -781,7 +937,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -792,7 +950,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -807,8 +969,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -818,8 +984,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -829,8 +999,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -841,7 +1015,11 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -856,8 +1034,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -867,8 +1049,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -878,8 +1064,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -890,7 +1080,11 @@ export class CommentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -905,8 +1099,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -916,8 +1114,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -927,8 +1129,12 @@ export class CommentServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -938,7 +1144,7 @@ export class CommentServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -953,7 +1159,8 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -964,7 +1171,8 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -975,7 +1183,11 @@ export class CommentServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -990,8 +1202,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -1001,8 +1217,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -1012,8 +1232,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -1024,7 +1248,7 @@ export class CommentServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -1040,7 +1264,9 @@ export class CommentServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -1051,7 +1277,9 @@ export class CommentServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -1062,7 +1290,9 @@ export class CommentServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -1073,7 +1303,11 @@ export class CommentServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -1088,8 +1322,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -1099,8 +1337,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -1110,8 +1352,12 @@ export class CommentServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -1122,7 +1368,7 @@ export class CommentServiceClient { */ close(): Promise { if (this.commentServiceStub && !this._terminated) { - return this.commentServiceStub.then(stub => { + return this.commentServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1130,4 +1376,4 @@ export class CommentServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/feed_service_client.ts b/packages/google-cloud-support/src/v2beta/feed_service_client.ts index 94bcb6de26dc..5853c96a8ce7 100644 --- a/packages/google-cloud-support/src/v2beta/feed_service_client.ts +++ b/packages/google-cloud-support/src/v2beta/feed_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class FeedServiceClient { 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('support'); @@ -57,9 +64,9 @@ export class FeedServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - feedServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + feedServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of FeedServiceClient. @@ -100,21 +107,42 @@ export class FeedServiceClient { * const client = new FeedServiceClient({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 FeedServiceClient; - 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 = 'cloudsupport.' + 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; @@ -139,7 +167,7 @@ export class FeedServiceClient { 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; @@ -153,10 +181,7 @@ export class FeedServiceClient { } // 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 { @@ -178,28 +203,30 @@ export class FeedServiceClient { // Create useful helper objects for these. this.pathTemplates = { organizationCasePathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}' - ), - organizationCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/attachments/{attachment_id}' + 'organizations/{organization}/cases/{case}', ), + organizationCaseAttachmentIdPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/attachments/{attachment_id}', + ), organizationCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/comments/{comment}' - ), - organizationCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'organizations/{organization}/cases/{case}/emailMessages/{email_message}' + 'organizations/{organization}/cases/{case}/comments/{comment}', ), + organizationCaseEmailMessagesPathTemplate: + new this._gaxModule.PathTemplate( + 'organizations/{organization}/cases/{case}/emailMessages/{email_message}', + ), projectCasePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}' + 'projects/{project}/cases/{case}', ), projectCaseAttachmentIdPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/attachments/{attachment_id}' + 'projects/{project}/cases/{case}/attachments/{attachment_id}', ), projectCaseCommentPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/comments/{comment}' + 'projects/{project}/cases/{case}/comments/{comment}', ), projectCaseEmailMessagesPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/cases/{case}/emailMessages/{email_message}' + 'projects/{project}/cases/{case}/emailMessages/{email_message}', ), }; @@ -207,14 +234,20 @@ export class FeedServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - showFeed: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'feedItems') + showFeed: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'feedItems', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.support.v2beta.FeedService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.support.v2beta.FeedService', + 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,40 @@ export class FeedServiceClient { // Put together the "service stub" for // google.cloud.support.v2beta.FeedService. this.feedServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.support.v2beta.FeedService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.support.v2beta.FeedService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.support.v2beta.FeedService, - 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 feedServiceStubMethods = - ['showFeed']; + const feedServiceStubMethods = ['showFeed']; for (const methodName of feedServiceStubMethods) { const callPromise = this.feedServiceStub.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 +326,14 @@ export class FeedServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -302,8 +344,14 @@ export class FeedServiceClient { * @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 'cloudsupport.googleapis.com'; } @@ -334,9 +382,7 @@ export class FeedServiceClient { * @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 +391,9 @@ export class FeedServiceClient { * 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; @@ -358,97 +405,116 @@ export class FeedServiceClient { // -- Service calls -- // ------------------- - /** - * Show items in the feed of this case, including case emails, - * attachments, and comments. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.FeedItem|FeedItem}. - * 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 `showFeedAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } - * for more details and examples. - */ + /** + * Show items in the feed of this case, including case emails, + * attachments, and comments. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.support.v2beta.FeedItem|FeedItem}. + * 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 `showFeedAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showFeed( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]>; + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ] + >; showFeed( - request: protos.google.cloud.support.v2beta.IShowFeedRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): void; + request: protos.google.cloud.support.v2beta.IShowFeedRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): void; showFeed( - request: protos.google.cloud.support.v2beta.IShowFeedRequest, - callback: PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): void; + request: protos.google.cloud.support.v2beta.IShowFeedRequest, + callback: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): void; showFeed( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>, - callback?: PaginationCallback< + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>): - Promise<[ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]>|void { + | protos.google.cloud.support.v2beta.IShowFeedResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + callback?: PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + protos.google.cloud.support.v2beta.IShowFeedResponse | null | undefined, + protos.google.cloud.support.v2beta.IFeedItem + >, + ): Promise< + [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.support.v2beta.IShowFeedRequest, - protos.google.cloud.support.v2beta.IShowFeedResponse|null|undefined, - protos.google.cloud.support.v2beta.IFeedItem>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.support.v2beta.IShowFeedRequest, + | protos.google.cloud.support.v2beta.IShowFeedResponse + | null + | undefined, + protos.google.cloud.support.v2beta.IFeedItem + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('showFeed values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -457,124 +523,128 @@ export class FeedServiceClient { this._log.info('showFeed request %j', request); return this.innerApiCalls .showFeed(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.support.v2beta.IFeedItem[], - protos.google.cloud.support.v2beta.IShowFeedRequest|null, - protos.google.cloud.support.v2beta.IShowFeedResponse - ]) => { - this._log.info('showFeed values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.support.v2beta.IFeedItem[], + protos.google.cloud.support.v2beta.IShowFeedRequest | null, + protos.google.cloud.support.v2beta.IShowFeedResponse, + ]) => { + this._log.info('showFeed values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `showFeed`, 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 case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @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.support.v2beta.FeedItem|FeedItem} 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 `showFeedAsync()` - * method described below for async iteration which you can stop as 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 `showFeed`, 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 case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @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.support.v2beta.FeedItem|FeedItem} 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 `showFeedAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ showFeedStream( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + 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['showFeed']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showFeed stream %j', request); return this.descriptors.page.showFeed.createStream( this.innerApiCalls.showFeed as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `showFeed`, 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 case for which feed items should be - * listed. - * @param {string} [request.orderBy] - * Optional. Field to order feed items by, followed by `asc` or `desc` - * postfix. The only valid field is - * `creation_time`. This list is case-insensitive, default sorting order is - * ascending, and the redundant space characters are insignificant. - * - * Example: `creation_time desc` - * @param {number} [request.pageSize] - * Optional. The maximum number of feed items fetched with each request. - * @param {string} [request.pageToken] - * Optional. A token identifying the page of results to return. If - * unspecified, it retrieves the first page. - * @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.support.v2beta.FeedItem|FeedItem}. 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/v2beta/feed_service.show_feed.js - * region_tag:cloudsupport_v2beta_generated_FeedService_ShowFeed_async - */ + /** + * Equivalent to `showFeed`, 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 case for which feed items should be + * listed. + * @param {string} [request.orderBy] + * Optional. Field to order feed items by, followed by `asc` or `desc` + * postfix. The only valid field is + * `creation_time`. This list is case-insensitive, default sorting order is + * ascending, and the redundant space characters are insignificant. + * + * Example: `creation_time desc` + * @param {number} [request.pageSize] + * Optional. The maximum number of feed items fetched with each request. + * @param {string} [request.pageToken] + * Optional. A token identifying the page of results to return. If + * unspecified, it retrieves the first page. + * @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.support.v2beta.FeedItem|FeedItem}. 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/v2beta/feed_service.show_feed.js + * region_tag:cloudsupport_v2beta_generated_FeedService_ShowFeed_async + */ showFeedAsync( - request?: protos.google.cloud.support.v2beta.IShowFeedRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.support.v2beta.IShowFeedRequest, + 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['showFeed']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('showFeed iterate %j', request); return this.descriptors.page.showFeed.asyncIterate( this.innerApiCalls['showFeed'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -588,7 +658,7 @@ export class FeedServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - organizationCasePath(organization:string,caseParam:string) { + organizationCasePath(organization: string, caseParam: string) { return this.pathTemplates.organizationCasePathTemplate.render({ organization: organization, case: caseParam, @@ -603,7 +673,9 @@ export class FeedServiceClient { * @returns {string} A string representing the organization. */ matchOrganizationFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).organization; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).organization; } /** @@ -614,7 +686,9 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromOrganizationCaseName(organizationCaseName: string) { - return this.pathTemplates.organizationCasePathTemplate.match(organizationCaseName).case; + return this.pathTemplates.organizationCasePathTemplate.match( + organizationCaseName, + ).case; } /** @@ -625,7 +699,11 @@ export class FeedServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - organizationCaseAttachmentIdPath(organization:string,caseParam:string,attachmentId:string) { + organizationCaseAttachmentIdPath( + organization: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.render({ organization: organization, case: caseParam, @@ -640,8 +718,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).organization; + matchOrganizationFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).organization; } /** @@ -651,8 +733,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).case; + matchCaseFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).case; } /** @@ -662,8 +748,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromOrganizationCaseAttachmentIdName(organizationCaseAttachmentIdName: string) { - return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match(organizationCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromOrganizationCaseAttachmentIdName( + organizationCaseAttachmentIdName: string, + ) { + return this.pathTemplates.organizationCaseAttachmentIdPathTemplate.match( + organizationCaseAttachmentIdName, + ).attachment_id; } /** @@ -674,7 +764,11 @@ export class FeedServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - organizationCaseCommentPath(organization:string,caseParam:string,comment:string) { + organizationCaseCommentPath( + organization: string, + caseParam: string, + comment: string, + ) { return this.pathTemplates.organizationCaseCommentPathTemplate.render({ organization: organization, case: caseParam, @@ -689,8 +783,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).organization; + matchOrganizationFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).organization; } /** @@ -700,8 +798,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).case; + matchCaseFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).case; } /** @@ -711,8 +813,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_comment resource. * @returns {string} A string representing the comment. */ - matchCommentFromOrganizationCaseCommentName(organizationCaseCommentName: string) { - return this.pathTemplates.organizationCaseCommentPathTemplate.match(organizationCaseCommentName).comment; + matchCommentFromOrganizationCaseCommentName( + organizationCaseCommentName: string, + ) { + return this.pathTemplates.organizationCaseCommentPathTemplate.match( + organizationCaseCommentName, + ).comment; } /** @@ -723,7 +829,11 @@ export class FeedServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - organizationCaseEmailMessagesPath(organization:string,caseParam:string,emailMessage:string) { + organizationCaseEmailMessagesPath( + organization: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.render({ organization: organization, case: caseParam, @@ -738,8 +848,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the organization. */ - matchOrganizationFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).organization; + matchOrganizationFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).organization; } /** @@ -749,8 +863,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).case; + matchCaseFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).case; } /** @@ -760,8 +878,12 @@ export class FeedServiceClient { * A fully-qualified path representing organization_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromOrganizationCaseEmailMessagesName(organizationCaseEmailMessagesName: string) { - return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match(organizationCaseEmailMessagesName).email_message; + matchEmailMessageFromOrganizationCaseEmailMessagesName( + organizationCaseEmailMessagesName: string, + ) { + return this.pathTemplates.organizationCaseEmailMessagesPathTemplate.match( + organizationCaseEmailMessagesName, + ).email_message; } /** @@ -771,7 +893,7 @@ export class FeedServiceClient { * @param {string} caseParam * @returns {string} Resource name string. */ - projectCasePath(project:string,caseParam:string) { + projectCasePath(project: string, caseParam: string) { return this.pathTemplates.projectCasePathTemplate.render({ project: project, case: caseParam, @@ -786,7 +908,8 @@ export class FeedServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).project; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .project; } /** @@ -797,7 +920,8 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseName(projectCaseName: string) { - return this.pathTemplates.projectCasePathTemplate.match(projectCaseName).case; + return this.pathTemplates.projectCasePathTemplate.match(projectCaseName) + .case; } /** @@ -808,7 +932,11 @@ export class FeedServiceClient { * @param {string} attachment_id * @returns {string} Resource name string. */ - projectCaseAttachmentIdPath(project:string,caseParam:string,attachmentId:string) { + projectCaseAttachmentIdPath( + project: string, + caseParam: string, + attachmentId: string, + ) { return this.pathTemplates.projectCaseAttachmentIdPathTemplate.render({ project: project, case: caseParam, @@ -823,8 +951,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).project; + matchProjectFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).project; } /** @@ -834,8 +966,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).case; + matchCaseFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).case; } /** @@ -845,8 +981,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_attachment_id resource. * @returns {string} A string representing the attachment_id. */ - matchAttachmentIdFromProjectCaseAttachmentIdName(projectCaseAttachmentIdName: string) { - return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match(projectCaseAttachmentIdName).attachment_id; + matchAttachmentIdFromProjectCaseAttachmentIdName( + projectCaseAttachmentIdName: string, + ) { + return this.pathTemplates.projectCaseAttachmentIdPathTemplate.match( + projectCaseAttachmentIdName, + ).attachment_id; } /** @@ -857,7 +997,7 @@ export class FeedServiceClient { * @param {string} comment * @returns {string} Resource name string. */ - projectCaseCommentPath(project:string,caseParam:string,comment:string) { + projectCaseCommentPath(project: string, caseParam: string, comment: string) { return this.pathTemplates.projectCaseCommentPathTemplate.render({ project: project, case: caseParam, @@ -873,7 +1013,9 @@ export class FeedServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).project; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).project; } /** @@ -884,7 +1026,9 @@ export class FeedServiceClient { * @returns {string} A string representing the case. */ matchCaseFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).case; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).case; } /** @@ -895,7 +1039,9 @@ export class FeedServiceClient { * @returns {string} A string representing the comment. */ matchCommentFromProjectCaseCommentName(projectCaseCommentName: string) { - return this.pathTemplates.projectCaseCommentPathTemplate.match(projectCaseCommentName).comment; + return this.pathTemplates.projectCaseCommentPathTemplate.match( + projectCaseCommentName, + ).comment; } /** @@ -906,7 +1052,11 @@ export class FeedServiceClient { * @param {string} email_message * @returns {string} Resource name string. */ - projectCaseEmailMessagesPath(project:string,caseParam:string,emailMessage:string) { + projectCaseEmailMessagesPath( + project: string, + caseParam: string, + emailMessage: string, + ) { return this.pathTemplates.projectCaseEmailMessagesPathTemplate.render({ project: project, case: caseParam, @@ -921,8 +1071,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the project. */ - matchProjectFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).project; + matchProjectFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).project; } /** @@ -932,8 +1086,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the case. */ - matchCaseFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).case; + matchCaseFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).case; } /** @@ -943,8 +1101,12 @@ export class FeedServiceClient { * A fully-qualified path representing project_case_emailMessages resource. * @returns {string} A string representing the email_message. */ - matchEmailMessageFromProjectCaseEmailMessagesName(projectCaseEmailMessagesName: string) { - return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match(projectCaseEmailMessagesName).email_message; + matchEmailMessageFromProjectCaseEmailMessagesName( + projectCaseEmailMessagesName: string, + ) { + return this.pathTemplates.projectCaseEmailMessagesPathTemplate.match( + projectCaseEmailMessagesName, + ).email_message; } /** @@ -955,7 +1117,7 @@ export class FeedServiceClient { */ close(): Promise { if (this.feedServiceStub && !this._terminated) { - return this.feedServiceStub.then(stub => { + return this.feedServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -963,4 +1125,4 @@ export class FeedServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-support/src/v2beta/index.ts b/packages/google-cloud-support/src/v2beta/index.ts index 987b0997e1a2..c9b650585797 100644 --- a/packages/google-cloud-support/src/v2beta/index.ts +++ b/packages/google-cloud-support/src/v2beta/index.ts @@ -16,7 +16,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CaseAttachmentServiceClient} from './case_attachment_service_client'; -export {CaseServiceClient} from './case_service_client'; -export {CommentServiceClient} from './comment_service_client'; -export {FeedServiceClient} from './feed_service_client'; +export { CaseAttachmentServiceClient } from './case_attachment_service_client'; +export { CaseServiceClient } from './case_service_client'; +export { CommentServiceClient } from './comment_service_client'; +export { FeedServiceClient } from './feed_service_client'; diff --git a/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts index f3b5a06d0b38..5cfb2a310df6 100644 --- a/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-support/system-test/fixtures/sample/src/index.ts @@ -16,10 +16,16 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CaseAttachmentServiceClient, CaseServiceClient, CommentServiceClient} from '@google-cloud/support'; +import { + CaseAttachmentServiceClient, + CaseServiceClient, + CommentServiceClient, +} from '@google-cloud/support'; // check that the client class type name can be used -function doStuffWithCaseAttachmentServiceClient(client: CaseAttachmentServiceClient) { +function doStuffWithCaseAttachmentServiceClient( + client: CaseAttachmentServiceClient, +) { client.close(); } function doStuffWithCaseServiceClient(client: CaseServiceClient) { diff --git a/packages/google-cloud-support/system-test/install.ts b/packages/google-cloud-support/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-support/system-test/install.ts +++ b/packages/google-cloud-support/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-support/test/gapic_case_attachment_service_v2.ts b/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts index 8950d03df9ee..50977e2f9a1d 100644 --- a/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_case_attachment_service_v2.ts @@ -19,751 +19,1056 @@ 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 caseattachmentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2.CaseAttachmentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + 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 = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.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 = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient + .servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = caseattachmentserviceModule.v2.CaseAttachmentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 no option', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - fallback: true, - }); - assert(client); + it('has port', () => { + const port = + caseattachmentserviceModule.v2.CaseAttachmentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + fallback: true, }); + assert(client); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - await client.initialize(); - assert(client.caseAttachmentServiceStub); + it('has initialize method and supports deferred initialization', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + await client.initialize(); + assert(client.caseAttachmentServiceStub); + }); - it('has close method for the initialized client', done => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseAttachmentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseAttachmentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the non-initialized client', done => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has close method for the non-initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + 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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + 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('listAttachments', () => { - it('invokes listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); - const [response] = await client.listAttachments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + describe('listAttachments', () => { + it('invokes listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); + const [response] = await client.listAttachments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachments without error using callback', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttachments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IAttachment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listAttachments without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.innerApiCalls.listAttachments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttachments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IAttachment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttachments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttachments(request), expectedError); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttachments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAttachments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listAttachmentsStream without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Attachment) => { - 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.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listAttachmentsStream without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Attachment) => { + 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.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listAttachmentsStream with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listAttachmentsStream with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), - ]; - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.IAttachment[] = []; - const iterable = client.listAttachmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('uses async iteration with listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + generateSampleMessage(new protos.google.cloud.support.v2.Attachment()), + ]; + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.IAttachment[] = []; + const iterable = client.listAttachmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttachmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.IAttachment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('uses async iteration with listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttachmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.IAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); + }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts b/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts index cdb95eee4b21..4c25fa98a18f 100644 --- a/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_case_attachment_service_v2beta.ts @@ -19,951 +19,1378 @@ 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 caseattachmentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2beta.CaseAttachmentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - 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 = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('has universeDomain', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has port', () => { - const port = caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.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 = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient + .servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient + .apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universeDomain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('should create a client with no option', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); - assert(client); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universe_domain: 'example.com', }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('should create a client with gRPC fallback', () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - await client.initialize(); - assert(client.caseAttachmentServiceStub); + 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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 initialized client', done => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseAttachmentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the non-initialized client', done => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseAttachmentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = + caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient(); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - 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 caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + fallback: true, }); + assert(client); }); - describe('getAttachment', () => { - it('invokes getAttachment without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Attachment() - ); - client.innerApiCalls.getAttachment = stubSimpleCall(expectedResponse); - const [response] = await client.getAttachment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment without error using callback', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Attachment() - ); - client.innerApiCalls.getAttachment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAttachment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IAttachment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getAttachment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAttachment(request), expectedError); - const actualRequest = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getAttachment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getAttachment with closed client', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetAttachmentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetAttachmentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getAttachment(request), expectedError); - }); - }); - - describe('listAttachments', () => { - it('invokes listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); - const [response] = await client.listAttachments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments without error using callback', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.innerApiCalls.listAttachments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAttachments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IAttachment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listAttachments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAttachments(request), expectedError); - const actualRequest = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listAttachments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listAttachmentsStream without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Attachment) => { - 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.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('invokes listAttachmentsStream with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAttachmentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Attachment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Attachment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAttachments, request)); - assert( - (client.descriptors.page.listAttachments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments without error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Attachment()), - ]; - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; - const iterable = client.listAttachmentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listAttachments with error', async () => { - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListAttachmentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListAttachmentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listAttachments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAttachmentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listAttachments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - }); - - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + await client.initialize(); + assert(client.caseAttachmentServiceStub); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has close method for the initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); - - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseAttachmentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('has close method for the non-initialized client', (done) => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseAttachmentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; + }); + }); - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + 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('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + 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('getAttachment', () => { + it('invokes getAttachment without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ); + client.innerApiCalls.getAttachment = stubSimpleCall(expectedResponse); + const [response] = await client.getAttachment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ); + client.innerApiCalls.getAttachment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAttachment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IAttachment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes getAttachment with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getAttachment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getAttachment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getAttachment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes getAttachment with closed client', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetAttachmentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetAttachmentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getAttachment(request), expectedError); + }); + }); + + describe('listAttachments', () => { + it('invokes listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.innerApiCalls.listAttachments = stubSimpleCall(expectedResponse); + const [response] = await client.listAttachments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachments without error using callback', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.innerApiCalls.listAttachments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAttachments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IAttachment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('invokes listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listAttachments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listAttachments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listAttachments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachmentsStream without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Attachment) => { + 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.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('invokes listAttachmentsStream with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAttachmentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Attachment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Attachment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAttachments, request), + ); + assert( + (client.descriptors.page.listAttachments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('uses async iteration with listAttachments without error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.Attachment(), + ), + ]; + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; + const iterable = client.listAttachmentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + it('uses async iteration with listAttachments with error', async () => { + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListAttachmentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListAttachmentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listAttachments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAttachmentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IAttachment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAttachments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listAttachments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = + new caseattachmentserviceModule.v2beta.CaseAttachmentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_service_v2.ts b/packages/google-cloud-support/test/gapic_case_service_v2.ts index 791bd38a3921..a8199a7487ff 100644 --- a/packages/google-cloud-support/test/gapic_case_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_case_service_v2.ts @@ -19,1745 +19,2262 @@ 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 caseserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2.CaseServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + 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 = caseserviceModule.v2.CaseServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseserviceModule.v2.CaseServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseserviceModule.v2.CaseServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 = caseserviceModule.v2.CaseServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = caseserviceModule.v2.CaseServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseserviceModule.v2.CaseServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2.CaseServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2.CaseServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2.CaseServiceClient({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 caseserviceModule.v2.CaseServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = caseserviceModule.v2.CaseServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 caseserviceModule.v2.CaseServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 no option', () => { - const client = new caseserviceModule.v2.CaseServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseserviceModule.v2.CaseServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = caseserviceModule.v2.CaseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - await client.initialize(); - assert(client.caseServiceStub); - }); + it('should create a client with no option', () => { + const client = new caseserviceModule.v2.CaseServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + await client.initialize(); + assert(client.caseServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2.CaseServiceClient({ - 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 caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2.CaseServiceClient({ - 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 caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCase', () => { - it('invokes getCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); - const [response] = await client.getCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase 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 caseserviceModule.v2.CaseServiceClient({ + 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 getCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.getCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase 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 caseserviceModule.v2.CaseServiceClient({ + 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('getCase', () => { + it('invokes getCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); + const [response] = await client.getCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCase(request), expectedError); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.getCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCase(request), expectedError); - }); + it('invokes getCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCase(request), expectedError); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCase', () => { - it('invokes createCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); - const [response] = await client.createCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCase(request), expectedError); + }); + }); + + describe('createCase', () => { + it('invokes createCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); + const [response] = await client.createCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.createCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.createCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCase(request), expectedError); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCase(request), expectedError); - }); + it('invokes createCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCase(request), expectedError); + }); + }); + + describe('updateCase', () => { + it('invokes updateCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); + const [response] = await client.updateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCase', () => { - it('invokes updateCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); - const [response] = await client.updateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.updateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCase(request), expectedError); + }); + }); + + describe('escalateCase', () => { + it('invokes escalateCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); + const [response] = await client.escalateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCase(request), expectedError); - }); + it('invokes escalateCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.escalateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.escalateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('escalateCase', () => { - it('invokes escalateCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); - const [response] = await client.escalateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.escalateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.escalateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.escalateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.escalateCase(request), expectedError); + }); + }); + + describe('closeCase', () => { + it('invokes closeCase without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); + const [response] = await client.closeCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.escalateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.escalateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Case(), + ); + client.innerApiCalls.closeCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.closeCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.escalateCase(request), expectedError); - }); + it('invokes closeCase with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.closeCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('closeCase', () => { - it('invokes closeCase without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); - const [response] = await client.closeCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with closed client', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.closeCase(request), expectedError); + }); + }); + + describe('listCases', () => { + it('invokes listCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); + const [response] = await client.listCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.closeCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.listCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.closeCase(request), expectedError); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with closed client', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.closeCase(request), expectedError); + it('invokes listCasesStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.listCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + 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.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('listCases', () => { - it('invokes listCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); - const [response] = await client.listCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes listCases without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCases(request), expectedError); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases 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.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.listCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - 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.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.listCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICase[] = []; + const iterable = client.listCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCases', () => { + it('invokes searchCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); + const [response] = await client.searchCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICase[] = []; - const iterable = client.listCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes searchCases without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.innerApiCalls.searchCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.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.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes searchCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchCases', () => { - it('invokes searchCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); - const [response] = await client.searchCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes searchCasesStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.searchCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes searchCases without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCases(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases 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.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCasesStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - 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.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes searchCasesStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Case[] = []; + stream.on('data', (response: protos.google.cloud.support.v2.Case) => { + responses.push(response); }); - - it('invokes searchCasesStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCases without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - generateSampleMessage(new protos.google.cloud.support.v2.Case()), - ]; - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICase[] = []; - const iterable = client.searchCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate 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.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + generateSampleMessage(new protos.google.cloud.support.v2.Case()), + ]; + client.descriptors.page.searchCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICase[] = []; + const iterable = client.searchCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('searchCaseClassifications', () => { - it('invokes searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(expectedResponse); - const [response] = await client.searchCaseClassifications(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('uses async iteration with searchCases with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.searchCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCaseClassifications', () => { + it('invokes searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCall(expectedResponse); + const [response] = await client.searchCaseClassifications(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications without error using callback', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCaseClassifications( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.ICaseClassification[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications without error using callback', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCaseClassifications( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.support.v2.ICaseClassification[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCaseClassifications(request), expectedError); - }); + it('invokes searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchCaseClassifications = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.searchCaseClassifications(request), + expectedError, + ); + }); - it('invokes searchCaseClassificationsStream without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.CaseClassification) => { - 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.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + it('invokes searchCaseClassificationsStream without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCaseClassificationsStream with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('uses async iteration with searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.ICaseClassification[] = []; - const iterable = client.searchCaseClassificationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + it('invokes searchCaseClassificationsStream with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCaseClassificationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.ICaseClassification[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); }); - describe('Path templates', () => { - - describe('organization', async () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.ICaseClassification[] = + []; + const iterable = client.searchCaseClassificationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCaseClassificationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.ICaseClassification[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('organization', async () => { + const fakePath = '/rendered/path/organization'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath('organizationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_case_service_v2beta.ts b/packages/google-cloud-support/test/gapic_case_service_v2beta.ts index 3ebffb51fb85..393f115a34dd 100644 --- a/packages/google-cloud-support/test/gapic_case_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_case_service_v2beta.ts @@ -19,1837 +19,2436 @@ 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 caseserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2beta.CaseServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.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 = caseserviceModule.v2beta.CaseServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = caseserviceModule.v2beta.CaseServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('has universeDomain', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 = + caseserviceModule.v2beta.CaseServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + caseserviceModule.v2beta.CaseServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2beta.CaseServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2beta.CaseServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 caseserviceModule.v2beta.CaseServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('has port', () => { - const port = caseserviceModule.v2beta.CaseServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 caseserviceModule.v2beta.CaseServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 no option', () => { - const client = new caseserviceModule.v2beta.CaseServiceClient(); - 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 caseserviceModule.v2beta.CaseServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 caseserviceModule.v2beta.CaseServiceClient({ - fallback: true, - }); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new caseserviceModule.v2beta.CaseServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - await client.initialize(); - assert(client.caseServiceStub); - }); + it('has port', () => { + const port = caseserviceModule.v2beta.CaseServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the initialized client', done => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.caseServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient(); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.caseServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - 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 initialize method and supports deferred initialization', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + await client.initialize(); + assert(client.caseServiceStub); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - 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 initialized client', (done) => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.caseServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('getCase', () => { - it('invokes getCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); - const [response] = await client.getCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase 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 caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.caseServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.getCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase 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 caseserviceModule.v2beta.CaseServiceClient({ + 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 getCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCase(request), expectedError); - const actualRequest = (client.innerApiCalls.getCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCase 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 caseserviceModule.v2beta.CaseServiceClient({ + 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('getCase', () => { + it('invokes getCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.getCase = stubSimpleCall(expectedResponse); + const [response] = await client.getCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCase(request), expectedError); - }); + it('invokes getCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.getCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCase', () => { - it('invokes createCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); - const [response] = await client.createCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getCase(request), expectedError); + const actualRequest = (client.innerApiCalls.getCase as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.createCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCase(request), expectedError); + }); + }); + + describe('createCase', () => { + it('invokes createCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.createCase = stubSimpleCall(expectedResponse); + const [response] = await client.createCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCase(request), expectedError); - const actualRequest = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.createCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCaseRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCase(request), expectedError); - }); + it('invokes createCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCase', () => { - it('invokes updateCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); - const [response] = await client.updateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCaseRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCase(request), expectedError); + }); + }); + + describe('updateCase', () => { + it('invokes updateCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.updateCase = stubSimpleCall(expectedResponse); + const [response] = await client.updateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.updateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.updateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedHeaderRequestParams = `case.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.UpdateCaseRequest() - ); - request.case ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.UpdateCaseRequest', ['case', 'name']); - request.case.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCase(request), expectedError); - }); + it('invokes updateCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.UpdateCaseRequest(), + ); + request.case ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.UpdateCaseRequest', + ['case', 'name'], + ); + request.case.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCase(request), expectedError); + }); + }); + + describe('escalateCase', () => { + it('invokes escalateCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); + const [response] = await client.escalateCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('escalateCase', () => { - it('invokes escalateCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCall(expectedResponse); - const [response] = await client.escalateCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.escalateCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.escalateCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.escalateCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.escalateCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.escalateCase = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.escalateCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.escalateCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.escalateCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.escalateCase(request), expectedError); - const actualRequest = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.escalateCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes escalateCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.EscalateCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.EscalateCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.escalateCase(request), expectedError); + }); + }); + + describe('closeCase', () => { + it('invokes closeCase without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); + const [response] = await client.closeCase(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes escalateCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.EscalateCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.EscalateCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.escalateCase(request), expectedError); - }); + it('invokes closeCase without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Case(), + ); + client.innerApiCalls.closeCase = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.closeCase( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('closeCase', () => { - it('invokes closeCase without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCall(expectedResponse); - const [response] = await client.closeCase(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.closeCase(request), expectedError); + const actualRequest = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.closeCase as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Case() - ); - client.innerApiCalls.closeCase = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.closeCase( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes closeCase with closed client', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CloseCaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CloseCaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.closeCase(request), expectedError); + }); + }); + + describe('listCases', () => { + it('invokes listCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); + const [response] = await client.listCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.closeCase = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.closeCase(request), expectedError); - const actualRequest = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.closeCase as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCases without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.listCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes closeCase with closed client', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CloseCaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CloseCaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.closeCase(request), expectedError); - }); + it('invokes listCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCases', () => { - it('invokes listCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCall(expectedResponse); - const [response] = await client.listCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.listCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCases without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.listCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases 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.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCases(request), expectedError); - const actualRequest = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCasesStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCasesStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.listCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - 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.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.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.listCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCases, request), + ); + assert( + (client.descriptors.page.listCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCasesStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCases, request)); - assert( - (client.descriptors.page.listCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.listCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + const iterable = client.listCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - const iterable = client.listCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCases.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCases', () => { + it('invokes searchCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); + const [response] = await client.searchCases(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes searchCases without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.innerApiCalls.searchCases = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCases( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.ICase[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchCases', () => { - it('invokes searchCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCall(expectedResponse); - const [response] = await client.searchCases(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchCases = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchCases(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchCases as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchCases without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.innerApiCalls.searchCases = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCases( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICase[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes searchCasesStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.searchCases.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchCases = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCases(request), expectedError); - const actualRequest = (client.innerApiCalls.searchCases as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchCases 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.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes searchCasesStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - 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.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes searchCasesStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.searchCasesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Case[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Case) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCasesStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCasesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Case[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Case) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCases.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCases, request)); - assert( - (client.descriptors.page.searchCases.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.searchCases.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.searchCases, request), + ); + assert( + (client.descriptors.page.searchCases.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), - ]; - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - const iterable = client.searchCasesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Case()), + ]; + client.descriptors.page.searchCases.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + const iterable = client.searchCasesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with searchCases with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCasesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.SearchCasesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCasesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICase[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.searchCases.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with searchCases with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCasesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.SearchCasesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.searchCases.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.searchCasesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICase[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.searchCases.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.searchCases.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('searchCaseClassifications', () => { + it('invokes searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCall(expectedResponse); + const [response] = await client.searchCaseClassifications(request); + assert.deepStrictEqual(response, expectedResponse); }); - describe('searchCaseClassifications', () => { - it('invokes searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(expectedResponse); - const [response] = await client.searchCaseClassifications(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications without error using callback', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.innerApiCalls.searchCaseClassifications = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchCaseClassifications( + request, + ( + err?: Error | null, + result?: + | protos.google.cloud.support.v2beta.ICaseClassification[] + | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes searchCaseClassifications without error using callback', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - );const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.innerApiCalls.searchCaseClassifications = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchCaseClassifications( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.ICaseClassification[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.searchCaseClassifications = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.searchCaseClassifications(request), + expectedError, + ); + }); - it('invokes searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.searchCaseClassifications = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchCaseClassifications(request), expectedError); + it('invokes searchCaseClassificationsStream without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes searchCaseClassificationsStream without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.CaseClassification) => { - 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.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + stream.on('error', (err: Error) => { + reject(err); }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('invokes searchCaseClassificationsStream with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.searchCaseClassificationsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.CaseClassification[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.CaseClassification) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.searchCaseClassifications.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.searchCaseClassifications, request)); + it('invokes searchCaseClassificationsStream with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.searchCaseClassificationsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.CaseClassification[] = + []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.CaseClassification) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with searchCaseClassifications without error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - generateSampleMessage(new protos.google.cloud.support.v2beta.CaseClassification()), - ]; - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = []; - const iterable = client.searchCaseClassificationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + ( + client.descriptors.page.searchCaseClassifications + .createStream as SinonStub + ) + .getCall(0) + .calledWith(client.innerApiCalls.searchCaseClassifications, request), + ); + }); - it('uses async iteration with searchCaseClassifications with error', async () => { - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest() - ); - const expectedError = new Error('expected'); - client.descriptors.page.searchCaseClassifications.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.searchCaseClassificationsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.searchCaseClassifications.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + it('uses async iteration with searchCaseClassifications without error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.CaseClassification(), + ), + ]; + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = + []; + const iterable = client.searchCaseClassificationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); }); - describe('Path templates', () => { - - describe('organization', async () => { - const fakePath = "/rendered/path/organization"; - const expectedParameters = { - organization: "organizationValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationPath', () => { - const result = client.organizationPath("organizationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationName', () => { - const result = client.matchOrganizationFromOrganizationName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with searchCaseClassifications with error', async () => { + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.SearchCaseClassificationsRequest(), + ); + const expectedError = new Error('expected'); + client.descriptors.page.searchCaseClassifications.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.searchCaseClassificationsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.ICaseClassification[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.searchCaseClassifications + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); + + describe('Path templates', () => { + describe('organization', async () => { + const fakePath = '/rendered/path/organization'; + const expectedParameters = { + organization: 'organizationValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationPath', () => { + const result = client.organizationPath('organizationValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.organizationPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationName', () => { + const result = client.matchOrganizationFromOrganizationName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new caseserviceModule.v2beta.CaseServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new caseserviceModule.v2beta.CaseServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_comment_service_v2.ts b/packages/google-cloud-support/test/gapic_comment_service_v2.ts index b686f324981c..55227f27da01 100644 --- a/packages/google-cloud-support/test/gapic_comment_service_v2.ts +++ b/packages/google-cloud-support/test/gapic_comment_service_v2.ts @@ -19,859 +19,1161 @@ 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 commentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2.CommentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + 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 = commentserviceModule.v2.CommentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = commentserviceModule.v2.CommentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new commentserviceModule.v2.CommentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 = + commentserviceModule.v2.CommentServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + commentserviceModule.v2.CommentServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new commentserviceModule.v2.CommentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2.CommentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2.CommentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2.CommentServiceClient({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 commentserviceModule.v2.CommentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = commentserviceModule.v2.CommentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 commentserviceModule.v2.CommentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 no option', () => { - const client = new commentserviceModule.v2.CommentServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new commentserviceModule.v2.CommentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = commentserviceModule.v2.CommentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - await client.initialize(); - assert(client.commentServiceStub); - }); + it('should create a client with no option', () => { + const client = new commentserviceModule.v2.CommentServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.commentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + await client.initialize(); + assert(client.commentServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2.CommentServiceClient({ - 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 commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.commentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2.CommentServiceClient({ - 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 commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createComment', () => { - it('invokes createComment without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); - const [response] = await client.createComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment 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 commentserviceModule.v2.CommentServiceClient({ + 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 createComment without error using callback', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment 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 commentserviceModule.v2.CommentServiceClient({ + 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('createComment', () => { + it('invokes createComment without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); + const [response] = await client.createComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createComment(request), expectedError); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment without error using callback', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2.Comment(), + ); + client.innerApiCalls.createComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with closed client', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createComment(request), expectedError); - }); + it('invokes createComment with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listComments', () => { - it('invokes listComments without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); - const [response] = await client.listComments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment with closed client', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createComment(request), expectedError); + }); + }); + + describe('listComments', () => { + it('invokes listComments without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); + const [response] = await client.listComments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments without error using callback', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listComments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2.IComment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments without error using callback', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.innerApiCalls.listComments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listComments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2.IComment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listComments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listComments(request), expectedError); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listComments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listComments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCommentsStream without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.descriptors.page.listComments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Comment) => { - 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.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCommentsStream without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.descriptors.page.listComments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCommentsStream with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream 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.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listComments without error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2.Comment()), - ]; - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2.IComment[] = []; - const iterable = client.listCommentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCommentsStream with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listComments with error', async () => { - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCommentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2.IComment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate 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.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments without error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2.Comment()), + ]; + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2.IComment[] = []; + const iterable = client.listCommentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments with error', async () => { + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCommentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2.IComment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts b/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts index 448533a0f6ef..828a9a75b96e 100644 --- a/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_comment_service_v2beta.ts @@ -19,1059 +19,1453 @@ 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 commentserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2beta.CommentServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + 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 = commentserviceModule.v2beta.CommentServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = commentserviceModule.v2beta.CommentServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 = + commentserviceModule.v2beta.CommentServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + commentserviceModule.v2beta.CommentServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2beta.CommentServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2beta.CommentServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 commentserviceModule.v2beta.CommentServiceClient({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 commentserviceModule.v2beta.CommentServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = commentserviceModule.v2beta.CommentServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 commentserviceModule.v2beta.CommentServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 no option', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new commentserviceModule.v2beta.CommentServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = commentserviceModule.v2beta.CommentServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - await client.initialize(); - assert(client.commentServiceStub); - }); + it('should create a client with no option', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.commentServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.commentServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + await client.initialize(); + assert(client.commentServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - 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 commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.commentServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - 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 commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.commentServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createComment', () => { - it('invokes createComment without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); - const [response] = await client.createComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment 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 commentserviceModule.v2beta.CommentServiceClient({ + 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 createComment without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.createComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment 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 commentserviceModule.v2beta.CommentServiceClient({ + 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('createComment', () => { + it('invokes createComment without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.createComment = stubSimpleCall(expectedResponse); + const [response] = await client.createComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createComment(request), expectedError); - const actualRequest = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.createComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createComment with closed client', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.CreateCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.CreateCommentRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createComment(request), expectedError); - }); + it('invokes createComment with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getComment', () => { - it('invokes getComment without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.getComment = stubSimpleCall(expectedResponse); - const [response] = await client.getComment(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createComment with closed client', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.CreateCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.CreateCommentRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createComment(request), expectedError); + }); + }); + + describe('getComment', () => { + it('invokes getComment without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.getComment = stubSimpleCall(expectedResponse); + const [response] = await client.getComment(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.support.v2beta.Comment() - ); - client.innerApiCalls.getComment = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getComment( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getComment without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.support.v2beta.Comment(), + ); + client.innerApiCalls.getComment = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getComment( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getComment = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getComment(request), expectedError); - const actualRequest = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getComment as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getComment with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getComment = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getComment(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getComment as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getComment with closed client', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.GetCommentRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.GetCommentRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getComment(request), expectedError); - }); + it('invokes getComment with closed client', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.GetCommentRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.GetCommentRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getComment(request), expectedError); + }); + }); + + describe('listComments', () => { + it('invokes listComments without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); + const [response] = await client.listComments(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listComments', () => { - it('invokes listComments without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCall(expectedResponse); - const [response] = await client.listComments(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments without error using callback', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.innerApiCalls.listComments = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listComments( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IComment[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments without error using callback', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.innerApiCalls.listComments = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listComments( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IComment[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listComments with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listComments = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listComments(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listComments as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listComments with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listComments = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listComments(request), expectedError); - const actualRequest = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listComments as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCommentsStream without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.descriptors.page.listComments.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCommentsStream without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.descriptors.page.listComments.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Comment) => { - 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.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream 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.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCommentsStream with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCommentsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.Comment[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.Comment) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listComments, request)); - assert( - (client.descriptors.page.listComments.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCommentsStream with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listCommentsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.Comment[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.Comment) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listComments without error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), - ]; - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IComment[] = []; - const iterable = client.listCommentsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate 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.listComments.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listComments, request), + ); + assert( + (client.descriptors.page.listComments.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listComments with error', async () => { - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ListCommentsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ListCommentsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listComments.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCommentsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IComment[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listComments.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listComments without error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + generateSampleMessage(new protos.google.cloud.support.v2beta.Comment()), + ]; + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IComment[] = []; + const iterable = client.listCommentsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listComments with error', async () => { + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ListCommentsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ListCommentsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listComments.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCommentsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IComment[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listComments.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listComments.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new commentserviceModule.v2beta.CommentServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new commentserviceModule.v2beta.CommentServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts b/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts index dbb55ffde01b..b05785c02beb 100644 --- a/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts +++ b/packages/google-cloud-support/test/gapic_feed_service_v2beta.ts @@ -19,843 +19,1210 @@ 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 feedserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v2beta.FeedServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + 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 = feedserviceModule.v2beta.FeedServiceClient.servicePath; - assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = feedserviceModule.v2beta.FeedServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 = + feedserviceModule.v2beta.FeedServiceClient.servicePath; + assert.strictEqual(servicePath, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + feedserviceModule.v2beta.FeedServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudsupport.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.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 feedserviceModule.v2beta.FeedServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 feedserviceModule.v2beta.FeedServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudsupport.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 feedserviceModule.v2beta.FeedServiceClient({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 feedserviceModule.v2beta.FeedServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudsupport.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = feedserviceModule.v2beta.FeedServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 feedserviceModule.v2beta.FeedServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual( + servicePath, + 'cloudsupport.configured.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 no option', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new feedserviceModule.v2beta.FeedServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = feedserviceModule.v2beta.FeedServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.feedServiceStub, undefined); - await client.initialize(); - assert(client.feedServiceStub); - }); + it('should create a client with no option', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.feedServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.feedServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.feedServiceStub, undefined); + await client.initialize(); + assert(client.feedServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - 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 feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.feedServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - 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 feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.feedServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('showFeed', () => { - it('invokes showFeed without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.innerApiCalls.showFeed = stubSimpleCall(expectedResponse); - const [response] = await client.showFeed(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed 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 feedserviceModule.v2beta.FeedServiceClient({ + 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 showFeed without error using callback', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.innerApiCalls.showFeed = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.showFeed( - request, - (err?: Error|null, result?: protos.google.cloud.support.v2beta.IFeedItem[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed 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 feedserviceModule.v2beta.FeedServiceClient({ + 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('showFeed', () => { + it('invokes showFeed without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.innerApiCalls.showFeed = stubSimpleCall(expectedResponse); + const [response] = await client.showFeed(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeed with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.showFeed = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.showFeed(request), expectedError); - const actualRequest = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.showFeed as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes showFeed without error using callback', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.innerApiCalls.showFeed = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.showFeed( + request, + ( + err?: Error | null, + result?: protos.google.cloud.support.v2beta.IFeedItem[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeedStream without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.descriptors.page.showFeed.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.showFeedStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.FeedItem) => { - 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.showFeed.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showFeed, request)); - assert( - (client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes showFeed with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.showFeed = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.showFeed(request), expectedError); + const actualRequest = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.showFeed as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes showFeedStream with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showFeed.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.showFeedStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; - stream.on('data', (response: protos.google.cloud.support.v2beta.FeedItem) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.showFeed, request)); - assert( - (client.descriptors.page.showFeed.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes showFeedStream without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.descriptors.page.showFeed.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.showFeedStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.FeedItem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with showFeed without error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - generateSampleMessage(new protos.google.cloud.support.v2beta.FeedItem()), - ]; - client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; - const iterable = client.showFeedAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showFeed.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.showFeed.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.showFeed, request), + ); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with showFeed with error', async () => { - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.support.v2beta.ShowFeedRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.support.v2beta.ShowFeedRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.showFeedAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.showFeed.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes showFeedStream with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showFeed.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.showFeedStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.support.v2beta.FeedItem[] = []; + stream.on( + 'data', + (response: protos.google.cloud.support.v2beta.FeedItem) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.showFeed, request), + ); + assert( + (client.descriptors.page.showFeed.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('organizationCase', async () => { - const fakePath = "/rendered/path/organizationCase"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCasePath', () => { - const result = client.organizationCasePath("organizationValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseName', () => { - const result = client.matchOrganizationFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseName', () => { - const result = client.matchCaseFromOrganizationCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with showFeed without error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + generateSampleMessage( + new protos.google.cloud.support.v2beta.FeedItem(), + ), + ]; + client.descriptors.page.showFeed.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; + const iterable = client.showFeedAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.showFeed.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.showFeed.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('organizationCaseAttachmentId', async () => { - const fakePath = "/rendered/path/organizationCaseAttachmentId"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseAttachmentIdPath', () => { - const result = client.organizationCaseAttachmentIdPath("organizationValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchOrganizationFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromOrganizationCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with showFeed with error', async () => { + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.support.v2beta.ShowFeedRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.support.v2beta.ShowFeedRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.showFeed.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.showFeedAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.support.v2beta.IFeedItem[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.showFeed.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.showFeed.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('organizationCase', async () => { + const fakePath = '/rendered/path/organizationCase'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCasePath', () => { + const result = client.organizationCasePath( + 'organizationValue', + 'caseValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCasePathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseName', () => { + const result = + client.matchOrganizationFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseName', () => { + const result = client.matchCaseFromOrganizationCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.organizationCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseComment', async () => { - const fakePath = "/rendered/path/organizationCaseComment"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseCommentPath', () => { - const result = client.organizationCaseCommentPath("organizationValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseCommentName', () => { - const result = client.matchOrganizationFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseCommentName', () => { - const result = client.matchCaseFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromOrganizationCaseCommentName', () => { - const result = client.matchCommentFromOrganizationCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.organizationCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseAttachmentId', async () => { + const fakePath = '/rendered/path/organizationCaseAttachmentId'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseAttachmentIdPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseAttachmentIdPath', () => { + const result = client.organizationCaseAttachmentIdPath( + 'organizationValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchOrganizationFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchCaseFromOrganizationCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromOrganizationCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromOrganizationCaseAttachmentIdName( + fakePath, + ); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.organizationCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('organizationCaseEmailMessages', async () => { - const fakePath = "/rendered/path/organizationCaseEmailMessages"; - const expectedParameters = { - organization: "organizationValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('organizationCaseEmailMessagesPath', () => { - const result = client.organizationCaseEmailMessagesPath("organizationValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchOrganizationFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "organizationValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromOrganizationCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseComment', async () => { + const fakePath = '/rendered/path/organizationCaseComment'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.organizationCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('organizationCaseCommentPath', () => { + const result = client.organizationCaseCommentPath( + 'organizationValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseCommentName', () => { + const result = + client.matchOrganizationFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseCommentName', () => { + const result = + client.matchCaseFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromOrganizationCaseCommentName', () => { + const result = + client.matchCommentFromOrganizationCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.organizationCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCase', async () => { - const fakePath = "/rendered/path/projectCase"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCasePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCasePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCasePath', () => { - const result = client.projectCasePath("projectValue", "caseValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCasePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseName', () => { - const result = client.matchProjectFromProjectCaseName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseName', () => { - const result = client.matchCaseFromProjectCaseName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCasePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('organizationCaseEmailMessages', async () => { + const fakePath = '/rendered/path/organizationCaseEmailMessages'; + const expectedParameters = { + organization: 'organizationValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.organizationCaseEmailMessagesPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('organizationCaseEmailMessagesPath', () => { + const result = client.organizationCaseEmailMessagesPath( + 'organizationValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchOrganizationFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchOrganizationFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'organizationValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchCaseFromOrganizationCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromOrganizationCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromOrganizationCaseEmailMessagesName( + fakePath, + ); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.organizationCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseAttachmentId', async () => { - const fakePath = "/rendered/path/projectCaseAttachmentId"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - attachment_id: "attachmentIdValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseAttachmentIdPath', () => { - const result = client.projectCaseAttachmentIdPath("projectValue", "caseValue", "attachmentIdValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseAttachmentIdName', () => { - const result = client.matchProjectFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseAttachmentIdName', () => { - const result = client.matchCaseFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { - const result = client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); - assert.strictEqual(result, "attachmentIdValue"); - assert((client.pathTemplates.projectCaseAttachmentIdPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCase', async () => { + const fakePath = '/rendered/path/projectCase'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCasePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCasePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCasePath', () => { + const result = client.projectCasePath('projectValue', 'caseValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCasePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseName', () => { + const result = client.matchProjectFromProjectCaseName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseName', () => { + const result = client.matchCaseFromProjectCaseName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + (client.pathTemplates.projectCasePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseComment', async () => { - const fakePath = "/rendered/path/projectCaseComment"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - comment: "commentValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseCommentPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseCommentPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseCommentPath', () => { - const result = client.projectCaseCommentPath("projectValue", "caseValue", "commentValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseCommentPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseCommentName', () => { - const result = client.matchProjectFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseCommentName', () => { - const result = client.matchCaseFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCommentFromProjectCaseCommentName', () => { - const result = client.matchCommentFromProjectCaseCommentName(fakePath); - assert.strictEqual(result, "commentValue"); - assert((client.pathTemplates.projectCaseCommentPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseAttachmentId', async () => { + const fakePath = '/rendered/path/projectCaseAttachmentId'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + attachment_id: 'attachmentIdValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseAttachmentIdPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseAttachmentIdPath', () => { + const result = client.projectCaseAttachmentIdPath( + 'projectValue', + 'caseValue', + 'attachmentIdValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseAttachmentIdName', () => { + const result = + client.matchProjectFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseAttachmentIdName', () => { + const result = + client.matchCaseFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchAttachmentIdFromProjectCaseAttachmentIdName', () => { + const result = + client.matchAttachmentIdFromProjectCaseAttachmentIdName(fakePath); + assert.strictEqual(result, 'attachmentIdValue'); + assert( + ( + client.pathTemplates.projectCaseAttachmentIdPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectCaseEmailMessages', async () => { - const fakePath = "/rendered/path/projectCaseEmailMessages"; - const expectedParameters = { - project: "projectValue", - case: "caseValue", - email_message: "emailMessageValue", - }; - const client = new feedserviceModule.v2beta.FeedServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCaseEmailMessagesPath', () => { - const result = client.projectCaseEmailMessagesPath("projectValue", "caseValue", "emailMessageValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCaseEmailMessagesName', () => { - const result = client.matchProjectFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCaseFromProjectCaseEmailMessagesName', () => { - const result = client.matchCaseFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "caseValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { - const result = client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); - assert.strictEqual(result, "emailMessageValue"); - assert((client.pathTemplates.projectCaseEmailMessagesPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCaseComment', async () => { + const fakePath = '/rendered/path/projectCaseComment'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + comment: 'commentValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseCommentPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseCommentPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseCommentPath', () => { + const result = client.projectCaseCommentPath( + 'projectValue', + 'caseValue', + 'commentValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseCommentName', () => { + const result = client.matchProjectFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseCommentName', () => { + const result = client.matchCaseFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCommentFromProjectCaseCommentName', () => { + const result = client.matchCommentFromProjectCaseCommentName(fakePath); + assert.strictEqual(result, 'commentValue'); + assert( + ( + client.pathTemplates.projectCaseCommentPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); + + describe('projectCaseEmailMessages', async () => { + const fakePath = '/rendered/path/projectCaseEmailMessages'; + const expectedParameters = { + project: 'projectValue', + case: 'caseValue', + email_message: 'emailMessageValue', + }; + const client = new feedserviceModule.v2beta.FeedServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCaseEmailMessagesPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCaseEmailMessagesPath', () => { + const result = client.projectCaseEmailMessagesPath( + 'projectValue', + 'caseValue', + 'emailMessageValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCaseEmailMessagesName', () => { + const result = + client.matchProjectFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCaseFromProjectCaseEmailMessagesName', () => { + const result = + client.matchCaseFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'caseValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchEmailMessageFromProjectCaseEmailMessagesName', () => { + const result = + client.matchEmailMessageFromProjectCaseEmailMessagesName(fakePath); + assert.strictEqual(result, 'emailMessageValue'); + assert( + ( + client.pathTemplates.projectCaseEmailMessagesPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-support/webpack.config.js b/packages/google-cloud-support/webpack.config.js index 2251de740ea8..1fab5f9e2370 100644 --- a/packages/google-cloud-support/webpack.config.js +++ b/packages/google-cloud-support/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-talent/.eslintignore b/packages/google-cloud-talent/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-talent/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-talent/.eslintrc.json b/packages/google-cloud-talent/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-talent/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-talent/README.md b/packages/google-cloud-talent/README.md index c1ee3eb29d4b..56d3ae63613d 100644 --- a/packages/google-cloud-talent/README.md +++ b/packages/google-cloud-talent/README.md @@ -137,7 +137,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-talent/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`) @@ -147,7 +147,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-talent/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-talent/protos/protos.d.ts b/packages/google-cloud-talent/protos/protos.d.ts index 97313c45e830..dec27978082d 100644 --- a/packages/google-cloud-talent/protos/protos.d.ts +++ b/packages/google-cloud-talent/protos/protos.d.ts @@ -16091,6 +16091,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -16108,6 +16111,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 @@ -16808,6 +16814,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -16822,6 +16831,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 @@ -16900,6 +16912,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 { @@ -17226,6 +17350,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -17240,6 +17367,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 @@ -17564,6 +17694,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, @@ -17680,6 +17913,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -17710,6 +17944,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -17759,6 +17996,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -17893,6 +18133,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -17934,6 +18177,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 @@ -18781,6 +19027,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -18807,6 +19056,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 @@ -19741,6 +19993,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); @@ -19796,6 +20051,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[]; @@ -20016,6 +20274,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. */ @@ -20254,6 +20627,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -20276,6 +20652,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[]; @@ -20868,6 +21247,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. */ @@ -20897,6 +21282,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 @@ -21019,6 +21410,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. */ @@ -21138,8 +21639,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. */ @@ -21154,8 +21658,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. @@ -21688,6 +22195,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-talent/protos/protos.js b/packages/google-cloud-talent/protos/protos.js index 809b106a8f71..e7ddb465776c 100644 --- a/packages/google-cloud-talent/protos/protos.js +++ b/packages/google-cloud-talent/protos/protos.js @@ -42782,6 +42782,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -42816,6 +42817,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 @@ -42848,6 +42857,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; }; @@ -42899,6 +42910,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; @@ -42950,6 +42965,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; }; @@ -42992,6 +43012,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; }; @@ -43010,8 +43035,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) { @@ -43019,6 +43046,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; }; @@ -44841,6 +44870,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -44866,6 +44896,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 @@ -44892,6 +44930,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; }; @@ -44932,6 +44972,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; @@ -44972,6 +45016,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; }; @@ -44992,6 +45041,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; }; @@ -45008,10 +45062,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; }; @@ -45041,6 +45099,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; })(); @@ -45917,6 +46227,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -45928,6 +46239,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) @@ -45942,6 +46254,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 @@ -45968,6 +46288,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; }; @@ -45998,7 +46321,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) @@ -46008,6 +46331,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; @@ -46048,6 +46394,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; }; @@ -46068,6 +46422,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; }; @@ -46084,10 +46445,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; }; @@ -46726,29 +47095,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; })(); @@ -46995,6 +47609,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 @@ -47009,6 +47624,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; @@ -47033,6 +47649,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 @@ -47055,6 +47672,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -47105,6 +47723,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 @@ -47226,6 +47852,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; }; @@ -47298,6 +47927,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 = []; @@ -47400,6 +48035,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"; @@ -47454,6 +48096,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47506,6 +48149,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"); @@ -47569,6 +48219,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -47634,6 +48288,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -47690,6 +48345,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; }; @@ -47738,6 +48398,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 */ /** @@ -47843,6 +48504,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 @@ -47895,6 +48564,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; }; @@ -47987,6 +48658,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -48100,6 +48775,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; }; @@ -48199,6 +48883,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; }; @@ -48228,6 +48932,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; @@ -48273,6 +48978,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; }; @@ -50317,6 +51024,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 */ /** @@ -50377,6 +51085,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 @@ -50414,6 +51130,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; }; @@ -50476,6 +51194,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -50544,6 +51266,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; }; @@ -50593,6 +51324,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; }; @@ -50617,6 +51368,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; @@ -50637,6 +51389,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; }; @@ -52955,6 +53709,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 @@ -53075,6 +53830,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 @@ -53149,6 +53912,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(); @@ -53250,6 +54015,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 = []; @@ -53385,6 +54154,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"; @@ -53573,6 +54347,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"); @@ -53670,6 +54449,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")) @@ -53702,6 +54482,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) @@ -53974,6 +54756,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -54015,103 +54798,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; @@ -54706,6 +55975,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 */ @@ -54749,6 +56019,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 @@ -54787,6 +56065,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(); @@ -54838,6 +56118,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 = []; @@ -54890,6 +56174,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"; @@ -54923,6 +56212,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"); @@ -54955,6 +56249,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -54962,6 +56257,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) @@ -56429,6 +57726,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 */ /** @@ -56494,6 +57793,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 @@ -56530,6 +57845,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; }; @@ -56590,6 +57909,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; @@ -56680,6 +58007,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; }; @@ -56819,6 +58166,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; }; @@ -56842,6 +58237,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; @@ -56855,6 +58252,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; }; @@ -56982,6 +58383,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; })(); @@ -57166,6 +58780,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -57183,6 +58798,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -57231,6 +58847,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -57283,6 +58903,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -57391,7 +59015,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 */ /** @@ -57418,12 +59043,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. @@ -57449,10 +59082,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; }; @@ -57493,8 +59128,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: @@ -57537,6 +59176,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -57549,10 +59189,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; }; @@ -57580,6 +59225,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -57621,10 +59270,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; }; @@ -57643,13 +59297,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; }; @@ -58864,6 +60521,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-talent/protos/protos.json b/packages/google-cloud-talent/protos/protos.json index 1a71aefab0df..5424bec49fae 100644 --- a/packages/google-cloud-talent/protos/protos.json +++ b/packages/google-cloud-talent/protos/protos.json @@ -4650,8 +4650,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": { @@ -4874,6 +4873,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -5014,6 +5017,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 + } + } } } }, @@ -5071,6 +5096,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -5132,6 +5162,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -5165,12 +5208,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, @@ -5209,6 +5259,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -5297,6 +5352,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -5522,6 +5581,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -5572,7 +5635,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -5736,6 +5806,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -5871,7 +5942,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -5899,6 +5971,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -5968,6 +6044,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 + } + } } } }, @@ -6056,6 +6152,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -6198,6 +6298,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -6208,6 +6309,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -6218,6 +6320,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -6228,6 +6331,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -6238,7 +6342,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" } }, @@ -6248,27 +6353,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, @@ -6313,7 +6429,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -6328,6 +6450,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 + } + } + } } } }, @@ -6355,11 +6504,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -6372,6 +6536,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -6457,6 +6627,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Timestamp": { "fields": { "seconds": { @@ -6697,6 +6875,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-talent/samples/generated/v4/snippet_metadata_google.cloud.talent.v4.json b/packages/google-cloud-talent/samples/generated/v4/snippet_metadata_google.cloud.talent.v4.json index ed3eb3b366bb..73c4d5da3ffe 100644 --- a/packages/google-cloud-talent/samples/generated/v4/snippet_metadata_google.cloud.talent.v4.json +++ b/packages/google-cloud-talent/samples/generated/v4/snippet_metadata_google.cloud.talent.v4.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-talent", - "version": "7.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-talent/samples/generated/v4beta1/snippet_metadata_google.cloud.talent.v4beta1.json b/packages/google-cloud-talent/samples/generated/v4beta1/snippet_metadata_google.cloud.talent.v4beta1.json index 7ce45c3c6381..69ae59f1092d 100644 --- a/packages/google-cloud-talent/samples/generated/v4beta1/snippet_metadata_google.cloud.talent.v4beta1.json +++ b/packages/google-cloud-talent/samples/generated/v4beta1/snippet_metadata_google.cloud.talent.v4beta1.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-talent", - "version": "7.1.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-talent/src/v4/company_service_client.ts b/packages/google-cloud-talent/src/v4/company_service_client.ts index 3b40b61e6902..08137b6bef81 100644 --- a/packages/google-cloud-talent/src/v4/company_service_client.ts +++ b/packages/google-cloud-talent/src/v4/company_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CompanyServiceClient { 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('talent'); @@ -57,9 +64,9 @@ export class CompanyServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - companyServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + companyServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CompanyServiceClient. @@ -100,21 +107,42 @@ export class CompanyServiceClient { * const client = new CompanyServiceClient({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 CompanyServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +167,7 @@ export class CompanyServiceClient { 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; @@ -153,10 +181,7 @@ export class CompanyServiceClient { } // 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 { @@ -178,13 +203,13 @@ export class CompanyServiceClient { // Create useful helper objects for these. this.pathTemplates = { companyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -192,14 +217,20 @@ export class CompanyServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCompanies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'companies') + listCompanies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'companies', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4.CompanyService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4.CompanyService', + 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 @@ -230,37 +261,46 @@ export class CompanyServiceClient { // Put together the "service stub" for // google.cloud.talent.v4.CompanyService. this.companyServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4.CompanyService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4.CompanyService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4.CompanyService, - 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 companyServiceStubMethods = - ['createCompany', 'getCompany', 'updateCompany', 'deleteCompany', 'listCompanies']; + const companyServiceStubMethods = [ + 'createCompany', + 'getCompany', + 'updateCompany', + 'deleteCompany', + 'listCompanies', + ]; for (const methodName of companyServiceStubMethods) { const callPromise = this.companyServiceStub.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; @@ -275,8 +315,14 @@ export class CompanyServiceClient { * @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 'jobs.googleapis.com'; } @@ -287,8 +333,14 @@ export class CompanyServiceClient { * @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 'jobs.googleapis.com'; } @@ -321,7 +373,7 @@ export class CompanyServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -331,8 +383,9 @@ export class CompanyServiceClient { * 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; @@ -343,502 +396,653 @@ export class CompanyServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new company entity. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {google.cloud.talent.v4.Company} request.company - * Required. The company 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 {@link protos.google.cloud.talent.v4.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/company_service.create_company.js - * region_tag:jobs_v4_generated_CompanyService_CreateCompany_async - */ + /** + * Creates a new company entity. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {google.cloud.talent.v4.Company} request.company + * Required. The company 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 {@link protos.google.cloud.talent.v4.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/company_service.create_company.js + * region_tag:jobs_v4_generated_CompanyService_CreateCompany_async + */ createCompany( - request?: protos.google.cloud.talent.v4.ICreateCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ICreateCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | undefined, + {} | undefined, + ] + >; createCompany( - request: protos.google.cloud.talent.v4.ICreateCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; createCompany( - request: protos.google.cloud.talent.v4.ICreateCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; createCompany( - request?: protos.google.cloud.talent.v4.ICreateCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.ICreateCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ICompany, + | protos.google.cloud.talent.v4.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.ICreateCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.ICreateCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves specified company. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the company to be retrieved. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/api-test-project/tenants/foo/companies/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/company_service.get_company.js - * region_tag:jobs_v4_generated_CompanyService_GetCompany_async - */ + /** + * Retrieves specified company. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the company to be retrieved. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/api-test-project/tenants/foo/companies/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/company_service.get_company.js + * region_tag:jobs_v4_generated_CompanyService_GetCompany_async + */ getCompany( - request?: protos.google.cloud.talent.v4.IGetCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IGetCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | undefined, + {} | undefined, + ] + >; getCompany( - request: protos.google.cloud.talent.v4.IGetCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCompany( - request: protos.google.cloud.talent.v4.IGetCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCompany( - request?: protos.google.cloud.talent.v4.IGetCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IGetCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IGetCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IGetCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified company. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4.Company} request.company - * Required. The company resource to replace the current resource in the - * system. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If {@link protos.google.cloud.talent.v4.UpdateCompanyRequest.update_mask|update_mask} - * is provided, only the specified fields in - * {@link protos.google.cloud.talent.v4.UpdateCompanyRequest.company|company} are updated. - * Otherwise all the fields are updated. - * - * A field mask to specify the company fields to be updated. Only - * top level fields of {@link protos.google.cloud.talent.v4.Company|Company} are - * 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 {@link protos.google.cloud.talent.v4.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/company_service.update_company.js - * region_tag:jobs_v4_generated_CompanyService_UpdateCompany_async - */ + /** + * Updates specified company. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4.Company} request.company + * Required. The company resource to replace the current resource in the + * system. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If {@link protos.google.cloud.talent.v4.UpdateCompanyRequest.update_mask|update_mask} + * is provided, only the specified fields in + * {@link protos.google.cloud.talent.v4.UpdateCompanyRequest.company|company} are updated. + * Otherwise all the fields are updated. + * + * A field mask to specify the company fields to be updated. Only + * top level fields of {@link protos.google.cloud.talent.v4.Company|Company} are + * 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 {@link protos.google.cloud.talent.v4.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/company_service.update_company.js + * region_tag:jobs_v4_generated_CompanyService_UpdateCompany_async + */ updateCompany( - request?: protos.google.cloud.talent.v4.IUpdateCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IUpdateCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | undefined, + {} | undefined, + ] + >; updateCompany( - request: protos.google.cloud.talent.v4.IUpdateCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCompany( - request: protos.google.cloud.talent.v4.IUpdateCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; updateCompany( - request?: protos.google.cloud.talent.v4.IUpdateCompanyRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4.IUpdateCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'company.name': request.company!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'company.name': request.company!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ICompany, + | protos.google.cloud.talent.v4.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ICompany, - protos.google.cloud.talent.v4.IUpdateCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ICompany, + protos.google.cloud.talent.v4.IUpdateCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified company. - * Prerequisite: The company has no jobs associated with it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the company to be deleted. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/foo/tenants/bar/companies/baz". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/company_service.delete_company.js - * region_tag:jobs_v4_generated_CompanyService_DeleteCompany_async - */ + /** + * Deletes specified company. + * Prerequisite: The company has no jobs associated with it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the company to be deleted. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/foo/tenants/bar/companies/baz". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/company_service.delete_company.js + * region_tag:jobs_v4_generated_CompanyService_DeleteCompany_async + */ deleteCompany( - request?: protos.google.cloud.talent.v4.IDeleteCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IDeleteCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | undefined, + {} | undefined, + ] + >; deleteCompany( - request: protos.google.cloud.talent.v4.IDeleteCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteCompany( - request: protos.google.cloud.talent.v4.IDeleteCompanyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteCompanyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteCompany( - request?: protos.google.cloud.talent.v4.IDeleteCompanyRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4.IDeleteCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteCompany request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all companies associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company}. - * 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 `listCompaniesAsync()` - * method described below for async iteration which you can stop as 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 companies associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company}. + * 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 `listCompaniesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCompanies( - request?: protos.google.cloud.talent.v4.IListCompaniesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ICompany[], - protos.google.cloud.talent.v4.IListCompaniesRequest|null, - protos.google.cloud.talent.v4.IListCompaniesResponse - ]>; + request?: protos.google.cloud.talent.v4.IListCompaniesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany[], + protos.google.cloud.talent.v4.IListCompaniesRequest | null, + protos.google.cloud.talent.v4.IListCompaniesResponse, + ] + >; listCompanies( - request: protos.google.cloud.talent.v4.IListCompaniesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListCompaniesRequest, - protos.google.cloud.talent.v4.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4.ICompany>): void; + request: protos.google.cloud.talent.v4.IListCompaniesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListCompaniesRequest, + protos.google.cloud.talent.v4.IListCompaniesResponse | null | undefined, + protos.google.cloud.talent.v4.ICompany + >, + ): void; listCompanies( - request: protos.google.cloud.talent.v4.IListCompaniesRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListCompaniesRequest, - protos.google.cloud.talent.v4.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4.ICompany>): void; + request: protos.google.cloud.talent.v4.IListCompaniesRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListCompaniesRequest, + protos.google.cloud.talent.v4.IListCompaniesResponse | null | undefined, + protos.google.cloud.talent.v4.ICompany + >, + ): void; listCompanies( - request?: protos.google.cloud.talent.v4.IListCompaniesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.talent.v4.IListCompaniesRequest, - protos.google.cloud.talent.v4.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4.ICompany>, - callback?: PaginationCallback< + request?: protos.google.cloud.talent.v4.IListCompaniesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4.IListCompaniesRequest, - protos.google.cloud.talent.v4.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4.ICompany>): - Promise<[ - protos.google.cloud.talent.v4.ICompany[], - protos.google.cloud.talent.v4.IListCompaniesRequest|null, - protos.google.cloud.talent.v4.IListCompaniesResponse - ]>|void { + | protos.google.cloud.talent.v4.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4.ICompany + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4.IListCompaniesRequest, + protos.google.cloud.talent.v4.IListCompaniesResponse | null | undefined, + protos.google.cloud.talent.v4.ICompany + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompany[], + protos.google.cloud.talent.v4.IListCompaniesRequest | null, + protos.google.cloud.talent.v4.IListCompaniesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IListCompaniesRequest, - protos.google.cloud.talent.v4.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4.ICompany>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4.IListCompaniesRequest, + | protos.google.cloud.talent.v4.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4.ICompany + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCompanies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -847,130 +1051,134 @@ export class CompanyServiceClient { this._log.info('listCompanies request %j', request); return this.innerApiCalls .listCompanies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4.ICompany[], - protos.google.cloud.talent.v4.IListCompaniesRequest|null, - protos.google.cloud.talent.v4.IListCompaniesResponse - ]) => { - this._log.info('listCompanies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4.ICompany[], + protos.google.cloud.talent.v4.IListCompaniesRequest | null, + protos.google.cloud.talent.v4.IListCompaniesResponse, + ]) => { + this._log.info('listCompanies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCompanies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company} 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 `listCompaniesAsync()` - * method described below for async iteration which you can stop as 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 `listCompanies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company} 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 `listCompaniesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCompaniesStream( - request?: protos.google.cloud.talent.v4.IListCompaniesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4.IListCompaniesRequest, + 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['listCompanies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCompanies stream %j', request); return this.descriptors.page.listCompanies.createStream( this.innerApiCalls.listCompanies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCompanies`, 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. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company}. 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/v4/company_service.list_companies.js - * region_tag:jobs_v4_generated_CompanyService_ListCompanies_async - */ + /** + * Equivalent to `listCompanies`, 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. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4.Company|Company}. 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/v4/company_service.list_companies.js + * region_tag:jobs_v4_generated_CompanyService_ListCompanies_async + */ listCompaniesAsync( - request?: protos.google.cloud.talent.v4.IListCompaniesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4.IListCompaniesRequest, + 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['listCompanies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCompanies iterate %j', request); return this.descriptors.page.listCompanies.asyncIterate( this.innerApiCalls['listCompanies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -985,7 +1193,7 @@ export class CompanyServiceClient { * @param {string} company * @returns {string} Resource name string. */ - companyPath(project:string,tenant:string,company:string) { + companyPath(project: string, tenant: string, company: string) { return this.pathTemplates.companyPathTemplate.render({ project: project, tenant: tenant, @@ -1034,7 +1242,7 @@ export class CompanyServiceClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,tenant:string,job:string) { + jobPath(project: string, tenant: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, tenant: tenant, @@ -1082,7 +1290,7 @@ export class CompanyServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -1119,7 +1327,7 @@ export class CompanyServiceClient { */ close(): Promise { if (this.companyServiceStub && !this._terminated) { - return this.companyServiceStub.then(stub => { + return this.companyServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1127,4 +1335,4 @@ export class CompanyServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4/completion_client.ts b/packages/google-cloud-talent/src/v4/completion_client.ts index b0b1c8f05fd8..42e81f7bb2d7 100644 --- a/packages/google-cloud-talent/src/v4/completion_client.ts +++ b/packages/google-cloud-talent/src/v4/completion_client.ts @@ -18,11 +18,16 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; 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 +49,7 @@ export class CompletionClient { 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('talent'); @@ -57,9 +62,9 @@ export class CompletionClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - completionStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + completionStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CompletionClient. @@ -100,21 +105,42 @@ export class CompletionClient { * const client = new CompletionClient({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 CompletionClient; - 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 = 'jobs.' + 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; @@ -139,7 +165,7 @@ export class CompletionClient { 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; @@ -153,10 +179,7 @@ export class CompletionClient { } // 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 { @@ -178,20 +201,23 @@ export class CompletionClient { // Create useful helper objects for these. this.pathTemplates = { companyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4.Completion', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4.Completion', + 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 @@ -222,36 +248,40 @@ export class CompletionClient { // Put together the "service stub" for // google.cloud.talent.v4.Completion. this.completionStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4.Completion') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4.Completion', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4.Completion, - 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 completionStubMethods = - ['completeQuery']; + const completionStubMethods = ['completeQuery']; for (const methodName of completionStubMethods) { const callPromise = this.completionStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +296,14 @@ export class CompletionClient { * @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 'jobs.googleapis.com'; } @@ -278,8 +314,14 @@ export class CompletionClient { * @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 'jobs.googleapis.com'; } @@ -312,7 +354,7 @@ export class CompletionClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -322,8 +364,9 @@ export class CompletionClient { * 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; @@ -334,127 +377,161 @@ export class CompletionClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * Intended for use by a job search auto-complete search box. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.tenant - * Required. Resource name of tenant the completion is performed within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string[]} request.languageCodes - * The list of languages of the query. This is - * the BCP-47 language code, such as "en-US" or "sr-Latn". - * For more information, see - * [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). - * - * The maximum number of allowed characters is 255. - * @param {number} request.pageSize - * Required. Completion result count. - * - * The maximum allowed page size is 10. - * @param {string} request.company - * If provided, restricts completion to specified company. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/foo/tenants/bar/companies/baz". - * @param {google.cloud.talent.v4.CompleteQueryRequest.CompletionScope} request.scope - * The scope of the completion. The defaults is - * {@link protos.google.cloud.talent.v4.CompleteQueryRequest.CompletionScope.PUBLIC|CompletionScope.PUBLIC}. - * @param {google.cloud.talent.v4.CompleteQueryRequest.CompletionType} request.type - * The completion topic. The default is - * {@link protos.google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMBINED|CompletionType.COMBINED}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.CompleteQueryResponse|CompleteQueryResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/completion.complete_query.js - * region_tag:jobs_v4_generated_Completion_CompleteQuery_async - */ + /** + * Completes the specified prefix with keyword suggestions. + * Intended for use by a job search auto-complete search box. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.tenant + * Required. Resource name of tenant the completion is performed within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string[]} request.languageCodes + * The list of languages of the query. This is + * the BCP-47 language code, such as "en-US" or "sr-Latn". + * For more information, see + * [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). + * + * The maximum number of allowed characters is 255. + * @param {number} request.pageSize + * Required. Completion result count. + * + * The maximum allowed page size is 10. + * @param {string} request.company + * If provided, restricts completion to specified company. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/foo/tenants/bar/companies/baz". + * @param {google.cloud.talent.v4.CompleteQueryRequest.CompletionScope} request.scope + * The scope of the completion. The defaults is + * {@link protos.google.cloud.talent.v4.CompleteQueryRequest.CompletionScope.PUBLIC|CompletionScope.PUBLIC}. + * @param {google.cloud.talent.v4.CompleteQueryRequest.CompletionType} request.type + * The completion topic. The default is + * {@link protos.google.cloud.talent.v4.CompleteQueryRequest.CompletionType.COMBINED|CompletionType.COMBINED}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.CompleteQueryResponse|CompleteQueryResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/completion.complete_query.js + * region_tag:jobs_v4_generated_Completion_CompleteQuery_async + */ completeQuery( - request?: protos.google.cloud.talent.v4.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ICompleteQueryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | undefined, + {} | undefined, + ] + >; completeQuery( - request: protos.google.cloud.talent.v4.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; completeQuery( - request: protos.google.cloud.talent.v4.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; completeQuery( - request?: protos.google.cloud.talent.v4.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.ICompleteQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tenant': request.tenant ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + tenant: request.tenant ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('completeQuery request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ICompleteQueryResponse, + | protos.google.cloud.talent.v4.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('completeQuery response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.completeQuery(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ICompleteQueryResponse, - protos.google.cloud.talent.v4.ICompleteQueryRequest|undefined, - {}|undefined - ]) => { - this._log.info('completeQuery response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .completeQuery(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ICompleteQueryResponse, + protos.google.cloud.talent.v4.ICompleteQueryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('completeQuery response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); @@ -472,7 +549,7 @@ export class CompletionClient { * @param {string} company * @returns {string} Resource name string. */ - companyPath(project:string,tenant:string,company:string) { + companyPath(project: string, tenant: string, company: string) { return this.pathTemplates.companyPathTemplate.render({ project: project, tenant: tenant, @@ -521,7 +598,7 @@ export class CompletionClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,tenant:string,job:string) { + jobPath(project: string, tenant: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, tenant: tenant, @@ -569,7 +646,7 @@ export class CompletionClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -606,7 +683,7 @@ export class CompletionClient { */ close(): Promise { if (this.completionStub && !this._terminated) { - return this.completionStub.then(stub => { + return this.completionStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -614,4 +691,4 @@ export class CompletionClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4/event_service_client.ts b/packages/google-cloud-talent/src/v4/event_service_client.ts index 7ec9a79387f4..3f2f29fda57a 100644 --- a/packages/google-cloud-talent/src/v4/event_service_client.ts +++ b/packages/google-cloud-talent/src/v4/event_service_client.ts @@ -18,11 +18,16 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; 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 +49,7 @@ export class EventServiceClient { 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('talent'); @@ -57,9 +62,9 @@ export class EventServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - eventServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + eventServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of EventServiceClient. @@ -100,21 +105,42 @@ export class EventServiceClient { * const client = new EventServiceClient({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 EventServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +165,7 @@ export class EventServiceClient { 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; @@ -153,10 +179,7 @@ export class EventServiceClient { } // 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 { @@ -178,20 +201,23 @@ export class EventServiceClient { // Create useful helper objects for these. this.pathTemplates = { companyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4.EventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4.EventService', + 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 @@ -222,36 +248,40 @@ export class EventServiceClient { // Put together the "service stub" for // google.cloud.talent.v4.EventService. this.eventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4.EventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4.EventService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4.EventService, - 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 eventServiceStubMethods = - ['createClientEvent']; + const eventServiceStubMethods = ['createClientEvent']; for (const methodName of eventServiceStubMethods) { const callPromise = this.eventServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -266,8 +296,14 @@ export class EventServiceClient { * @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 'jobs.googleapis.com'; } @@ -278,8 +314,14 @@ export class EventServiceClient { * @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 'jobs.googleapis.com'; } @@ -312,7 +354,7 @@ export class EventServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -322,8 +364,9 @@ export class EventServiceClient { * 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; @@ -334,108 +377,148 @@ export class EventServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Report events issued when end user interacts with customer's application - * that uses Cloud Talent Solution. You may inspect the created events in - * [self service - * tools](https://console.cloud.google.com/talent-solution/overview). - * [Learn - * more](https://cloud.google.com/talent-solution/docs/management-tools) - * about self service tools. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the event is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {google.cloud.talent.v4.ClientEvent} request.clientEvent - * Required. Events issued when end user interacts with customer's application - * that uses Cloud Talent Solution. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.ClientEvent|ClientEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/event_service.create_client_event.js - * region_tag:jobs_v4_generated_EventService_CreateClientEvent_async - */ + /** + * Report events issued when end user interacts with customer's application + * that uses Cloud Talent Solution. You may inspect the created events in + * [self service + * tools](https://console.cloud.google.com/talent-solution/overview). + * [Learn + * more](https://cloud.google.com/talent-solution/docs/management-tools) + * about self service tools. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the event is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {google.cloud.talent.v4.ClientEvent} request.clientEvent + * Required. Events issued when end user interacts with customer's application + * that uses Cloud Talent Solution. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.ClientEvent|ClientEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/event_service.create_client_event.js + * region_tag:jobs_v4_generated_EventService_CreateClientEvent_async + */ createClientEvent( - request?: protos.google.cloud.talent.v4.ICreateClientEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ICreateClientEventRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.IClientEvent, + protos.google.cloud.talent.v4.ICreateClientEventRequest | undefined, + {} | undefined, + ] + >; createClientEvent( - request: protos.google.cloud.talent.v4.ICreateClientEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateClientEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.IClientEvent, + | protos.google.cloud.talent.v4.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createClientEvent( - request: protos.google.cloud.talent.v4.ICreateClientEventRequest, - callback: Callback< - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateClientEventRequest, + callback: Callback< + protos.google.cloud.talent.v4.IClientEvent, + | protos.google.cloud.talent.v4.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createClientEvent( - request?: protos.google.cloud.talent.v4.ICreateClientEventRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4.ICreateClientEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.IClientEvent, + | protos.google.cloud.talent.v4.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.IClientEvent, + protos.google.cloud.talent.v4.ICreateClientEventRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createClientEvent request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.IClientEvent, + | protos.google.cloud.talent.v4.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createClientEvent response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createClientEvent(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.IClientEvent, - protos.google.cloud.talent.v4.ICreateClientEventRequest|undefined, - {}|undefined - ]) => { - this._log.info('createClientEvent response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createClientEvent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.IClientEvent, + protos.google.cloud.talent.v4.ICreateClientEventRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createClientEvent response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); @@ -453,7 +536,7 @@ export class EventServiceClient { * @param {string} company * @returns {string} Resource name string. */ - companyPath(project:string,tenant:string,company:string) { + companyPath(project: string, tenant: string, company: string) { return this.pathTemplates.companyPathTemplate.render({ project: project, tenant: tenant, @@ -502,7 +585,7 @@ export class EventServiceClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,tenant:string,job:string) { + jobPath(project: string, tenant: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, tenant: tenant, @@ -550,7 +633,7 @@ export class EventServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -587,7 +670,7 @@ export class EventServiceClient { */ close(): Promise { if (this.eventServiceStub && !this._terminated) { - return this.eventServiceStub.then(stub => { + return this.eventServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -595,4 +678,4 @@ export class EventServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4/index.ts b/packages/google-cloud-talent/src/v4/index.ts index 69bfaedb86e3..8f9887feb507 100644 --- a/packages/google-cloud-talent/src/v4/index.ts +++ b/packages/google-cloud-talent/src/v4/index.ts @@ -16,8 +16,8 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CompanyServiceClient} from './company_service_client'; -export {CompletionClient} from './completion_client'; -export {EventServiceClient} from './event_service_client'; -export {JobServiceClient} from './job_service_client'; -export {TenantServiceClient} from './tenant_service_client'; +export { CompanyServiceClient } from './company_service_client'; +export { CompletionClient } from './completion_client'; +export { EventServiceClient } from './event_service_client'; +export { JobServiceClient } from './job_service_client'; +export { TenantServiceClient } from './tenant_service_client'; diff --git a/packages/google-cloud-talent/src/v4/job_service_client.ts b/packages/google-cloud-talent/src/v4/job_service_client.ts index 770997894568..d2241f82f684 100644 --- a/packages/google-cloud-talent/src/v4/job_service_client.ts +++ b/packages/google-cloud-talent/src/v4/job_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 JobServiceClient { 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('talent'); @@ -57,10 +66,10 @@ export class JobServiceClient { 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; - jobServiceStub?: Promise<{[name: string]: Function}>; + jobServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of JobServiceClient. @@ -101,21 +110,42 @@ export class JobServiceClient { * const client = new JobServiceClient({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 JobServiceClient; - 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 = 'jobs.' + 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 JobServiceClient { 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 JobServiceClient { } // 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,16 +206,16 @@ export class JobServiceClient { // Create useful helper objects for these. this.pathTemplates = { companyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -196,8 +223,11 @@ export class JobServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + listJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'jobs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -206,45 +236,64 @@ export class JobServiceClient { // 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.longrunning.Operations.GetOperation',get: '/v4/{name=projects/*/operations/*}',}]; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v4/{name=projects/*/operations/*}', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const batchCreateJobsResponse = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchCreateJobsResponse') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchCreateJobsResponse', + ) as gax.protobuf.Type; const batchCreateJobsMetadata = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchOperationMetadata') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchOperationMetadata', + ) as gax.protobuf.Type; const batchUpdateJobsResponse = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchUpdateJobsResponse') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchUpdateJobsResponse', + ) as gax.protobuf.Type; const batchUpdateJobsMetadata = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchOperationMetadata') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchOperationMetadata', + ) as gax.protobuf.Type; const batchDeleteJobsResponse = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchDeleteJobsResponse') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchDeleteJobsResponse', + ) as gax.protobuf.Type; const batchDeleteJobsMetadata = protoFilesRoot.lookup( - '.google.cloud.talent.v4.BatchOperationMetadata') as gax.protobuf.Type; + '.google.cloud.talent.v4.BatchOperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { batchCreateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchCreateJobsResponse.decode.bind(batchCreateJobsResponse), - batchCreateJobsMetadata.decode.bind(batchCreateJobsMetadata)), + batchCreateJobsMetadata.decode.bind(batchCreateJobsMetadata), + ), batchUpdateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchUpdateJobsResponse.decode.bind(batchUpdateJobsResponse), - batchUpdateJobsMetadata.decode.bind(batchUpdateJobsMetadata)), + batchUpdateJobsMetadata.decode.bind(batchUpdateJobsMetadata), + ), batchDeleteJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchDeleteJobsResponse.decode.bind(batchDeleteJobsResponse), - batchDeleteJobsMetadata.decode.bind(batchDeleteJobsMetadata)) + batchDeleteJobsMetadata.decode.bind(batchDeleteJobsMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4.JobService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4.JobService', + 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 @@ -275,28 +324,44 @@ export class JobServiceClient { // Put together the "service stub" for // google.cloud.talent.v4.JobService. this.jobServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4.JobService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4.JobService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4.JobService, - 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 jobServiceStubMethods = - ['createJob', 'batchCreateJobs', 'getJob', 'updateJob', 'batchUpdateJobs', 'deleteJob', 'batchDeleteJobs', 'listJobs', 'searchJobs', 'searchJobsForAlert']; + const jobServiceStubMethods = [ + 'createJob', + 'batchCreateJobs', + 'getJob', + 'updateJob', + 'batchUpdateJobs', + 'deleteJob', + 'batchDeleteJobs', + 'listJobs', + 'searchJobs', + 'searchJobsForAlert', + ]; for (const methodName of jobServiceStubMethods) { const callPromise = this.jobServiceStub.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] || @@ -306,7 +371,7 @@ export class JobServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -321,8 +386,14 @@ export class JobServiceClient { * @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 'jobs.googleapis.com'; } @@ -333,8 +404,14 @@ export class JobServiceClient { * @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 'jobs.googleapis.com'; } @@ -367,7 +444,7 @@ export class JobServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -377,8 +454,9 @@ export class JobServiceClient { * 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; @@ -389,1655 +467,2036 @@ export class JobServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new job. - * - * Typically, the job becomes searchable within 10 seconds, but it may take - * up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {google.cloud.talent.v4.Job} request.job - * Required. The Job 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 {@link protos.google.cloud.talent.v4.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.create_job.js - * region_tag:jobs_v4_generated_JobService_CreateJob_async - */ + /** + * Creates a new job. + * + * Typically, the job becomes searchable within 10 seconds, but it may take + * up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {google.cloud.talent.v4.Job} request.job + * Required. The Job 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 {@link protos.google.cloud.talent.v4.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.create_job.js + * region_tag:jobs_v4_generated_JobService_CreateJob_async + */ createJob( - request?: protos.google.cloud.talent.v4.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ICreateJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | undefined, + {} | undefined, + ] + >; createJob( - request: protos.google.cloud.talent.v4.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request: protos.google.cloud.talent.v4.ICreateJobRequest, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateJobRequest, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request?: protos.google.cloud.talent.v4.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.ICreateJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.ICreateJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('createJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.ICreateJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves the specified job, whose status is OPEN or recently EXPIRED - * within the last 90 days. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the job to retrieve. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For - * example, "projects/foo/tenants/bar/jobs/baz". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.get_job.js - * region_tag:jobs_v4_generated_JobService_GetJob_async - */ + /** + * Retrieves the specified job, whose status is OPEN or recently EXPIRED + * within the last 90 days. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the job to retrieve. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For + * example, "projects/foo/tenants/bar/jobs/baz". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.get_job.js + * region_tag:jobs_v4_generated_JobService_GetJob_async + */ getJob( - request?: protos.google.cloud.talent.v4.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IGetJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | undefined, + {} | undefined, + ] + >; getJob( - request: protos.google.cloud.talent.v4.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getJob( - request: protos.google.cloud.talent.v4.IGetJobRequest, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetJobRequest, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getJob( - request?: protos.google.cloud.talent.v4.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IGetJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IGetJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IGetJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('getJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IGetJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified job. - * - * Typically, updated contents become visible in search results within 10 - * seconds, but it may take up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4.Job} request.job - * Required. The Job to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If {@link protos.google.cloud.talent.v4.UpdateJobRequest.update_mask|update_mask} is - * provided, only the specified fields in - * {@link protos.google.cloud.talent.v4.UpdateJobRequest.job|job} are updated. Otherwise - * all the fields are updated. - * - * A field mask to restrict the fields that are updated. Only - * top level fields of {@link protos.google.cloud.talent.v4.Job|Job} are 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 {@link protos.google.cloud.talent.v4.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.update_job.js - * region_tag:jobs_v4_generated_JobService_UpdateJob_async - */ + /** + * Updates specified job. + * + * Typically, updated contents become visible in search results within 10 + * seconds, but it may take up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4.Job} request.job + * Required. The Job to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If {@link protos.google.cloud.talent.v4.UpdateJobRequest.update_mask|update_mask} is + * provided, only the specified fields in + * {@link protos.google.cloud.talent.v4.UpdateJobRequest.job|job} are updated. Otherwise + * all the fields are updated. + * + * A field mask to restrict the fields that are updated. Only + * top level fields of {@link protos.google.cloud.talent.v4.Job|Job} are 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 {@link protos.google.cloud.talent.v4.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.update_job.js + * region_tag:jobs_v4_generated_JobService_UpdateJob_async + */ updateJob( - request?: protos.google.cloud.talent.v4.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IUpdateJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | undefined, + {} | undefined, + ] + >; updateJob( - request: protos.google.cloud.talent.v4.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; updateJob( - request: protos.google.cloud.talent.v4.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; updateJob( - request?: protos.google.cloud.talent.v4.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IUpdateJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'job.name': request.job!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'job.name': request.job!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.IJob, - protos.google.cloud.talent.v4.IUpdateJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.IJob, + protos.google.cloud.talent.v4.IUpdateJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 the specified job. - * - * Typically, the job becomes unsearchable within 10 seconds, but it may take - * up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the job to be deleted. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For - * example, "projects/foo/tenants/bar/jobs/baz". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/job_service.delete_job.js - * region_tag:jobs_v4_generated_JobService_DeleteJob_async - */ + /** + * Deletes the specified job. + * + * Typically, the job becomes unsearchable within 10 seconds, but it may take + * up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the job to be deleted. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For + * example, "projects/foo/tenants/bar/jobs/baz". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/job_service.delete_job.js + * region_tag:jobs_v4_generated_JobService_DeleteJob_async + */ deleteJob( - request?: protos.google.cloud.talent.v4.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IDeleteJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | undefined, + {} | undefined, + ] + >; deleteJob( - request: protos.google.cloud.talent.v4.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request: protos.google.cloud.talent.v4.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request?: protos.google.cloud.talent.v4.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IDeleteJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteJob request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Searches for jobs using the provided - * {@link protos.google.cloud.talent.v4.SearchJobsRequest|SearchJobsRequest}. - * - * This call constrains the - * {@link protos.google.cloud.talent.v4.Job.visibility|visibility} of jobs present in the - * database, and only returns jobs that the caller has permission to search - * against. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant to search within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {google.cloud.talent.v4.SearchJobsRequest.SearchMode} request.searchMode - * Mode of a search. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. - * @param {google.cloud.talent.v4.RequestMetadata} request.requestMetadata - * Required. The meta information collected about the job searcher, used to - * improve the search quality of the service. The identifiers (such as - * `user_id`) are provided by users, and must be unique and consistent. - * @param {google.cloud.talent.v4.JobQuery} request.jobQuery - * Query used to search against jobs, such as keyword, location filters, etc. - * @param {boolean} request.enableBroadening - * Controls whether to broaden the search when it produces sparse results. - * Broadened queries append results to the end of the matching results - * list. - * - * Defaults to false. - * @param {number[]} request.histogramQueries - * An expression specifies a histogram request against matching jobs. - * - * Expression syntax is an aggregation function call with histogram facets and - * other options. - * - * Available aggregation function calls are: - * * `count(string_histogram_facet)`: Count the number of matching entities, - * for each distinct attribute value. - * * `count(numeric_histogram_facet, list of buckets)`: Count the number of - * matching entities within each bucket. - * - * A maximum of 200 histogram buckets are supported. - * - * Data types: - * - * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. - * * String: string like "any string with backslash escape for quote(\")." - * * Number: whole number and floating point number like 10, -1 and -0.01. - * * List: list of elements with comma(,) separator surrounded by square - * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. - * - * Built-in constants: - * - * * MIN (minimum number similar to java Double.MIN_VALUE) - * * MAX (maximum number similar to java Double.MAX_VALUE) - * - * Built-in functions: - * - * * bucket(start, end[, label]): bucket built-in function creates a bucket - * with range of [start, end). Note that the end is exclusive, for example, - * bucket(1, MAX, "positive number") or bucket(1, 10). - * - * Job histogram facets: - * - * * company_display_name: histogram by - * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}. - * * employment_type: histogram by - * {@link protos.google.cloud.talent.v4.Job.employment_types|Job.employment_types}, for - * example, - * "FULL_TIME", "PART_TIME". - * * company_size (DEPRECATED): histogram by - * {@link protos.google.cloud.talent.v4.CompanySize|CompanySize}, for example, "SMALL", - * "MEDIUM", "BIG". - * * publish_time_in_day: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in days. - * Must specify list of numeric buckets in spec. - * * publish_time_in_month: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in months. - * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in years. - * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the - * {@link protos.google.cloud.talent.v4.Job.degree_types|Job.degree_types}, for example, - * "Bachelors", "Masters". - * * job_level: histogram by the - * {@link protos.google.cloud.talent.v4.Job.job_level|Job.job_level}, for example, "Entry - * Level". - * * country: histogram by the country code of jobs, for example, "US", "FR". - * * admin1: histogram by the admin1 code of jobs, which is a global - * placeholder referring to the state, province, or the particular term a - * country uses to define the geographic structure below the country level, - * for example, "CA", "IL". - * * city: histogram by a combination of the "city name, admin1 code". For - * example, "Mountain View, CA", "New York, NY". - * * admin1_country: histogram by a combination of the "admin1 code, country", - * for example, "CA, US", "IL, US". - * * city_coordinate: histogram by the city center's GPS coordinates (latitude - * and longitude), for example, 37.4038522,-122.0987765. Since the - * coordinates of a city center can change, customers may need to refresh - * them periodically. - * * locale: histogram by the - * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, for example, - * "en-US", - * "fr-FR". - * * language: histogram by the language subtag of the - * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, - * for example, "en", "fr". - * * category: histogram by the - * {@link protos.google.cloud.talent.v4.JobCategory|JobCategory}, for example, - * "COMPUTER_AND_IT", "HEALTHCARE". - * * base_compensation_unit: histogram by the - * {@link protos.google.cloud.talent.v4.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} - * of base salary, for example, "WEEKLY", "MONTHLY". - * * base_compensation: histogram by the base salary. Must specify list of - * numeric buckets to group results by. - * * annualized_base_compensation: histogram by the base annualized salary. - * Must specify list of numeric buckets to group results by. - * * annualized_total_compensation: histogram by the total annualized salary. - * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string - * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric - * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to - * group results by. - * - * Example expressions: - * - * * `count(admin1)` - * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), - * bucket(100000, MAX)])` - * * `count(string_custom_attribute["some-string-custom-attribute"])` - * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], - * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` - * @param {google.cloud.talent.v4.JobView} request.jobView - * The desired job attributes returned for jobs in the search response. - * Defaults to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if - * no value is specified. - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.page_token|page_token} is unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * job, and 10 means to return from the 11th job. This can be used for - * pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.maxPageSize - * A limit on the number of jobs returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within - * search results. See - * {@link protos.google.cloud.talent.v4.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} - * for an explanation of how to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. Default is - * `"relevance desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. Relevance thresholding of query results is only available - * with this ordering. - * * `"posting_publish_time desc"`: By - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * descending. - * * `"posting_update_time desc"`: By - * {@link protos.google.cloud.talent.v4.Job.posting_update_time|Job.posting_update_time} - * descending. - * * `"title"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} ascending. - * * `"title desc"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} - * descending. - * * `"annualized_base_compensation"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_base_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"annualized_total_compensation"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_total_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"custom_ranking desc"`: By the relevance score adjusted to the - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} - * with weight factor assigned by - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} - * in descending order. - * * Location sorting: Use the special syntax to order jobs by distance:
- * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
- * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
- * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by - * multiple locations. See details below.
- * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by - * multiple locations. See details below.
- * The string can have a maximum of 256 characters. When multiple distance - * centers are provided, a job that is close to any of the distance centers - * would have a high rank. When a job has multiple locations, the job - * location closest to one of the distance centers will be used. Jobs that - * don't have locations will be ranked at the bottom. Distance is calculated - * with a precision of 11.3 meters (37.4 feet). Diversification strategy is - * still applied unless explicitly disabled in - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.diversification_level|diversification_level}. - * @param {google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel} request.diversificationLevel - * Controls whether highly similar jobs are returned next to each other in - * the search results. Jobs are identified as highly similar based on - * their titles, job categories, and locations. Highly similar results are - * clustered so that only one representative job of the cluster is - * displayed to the job seeker higher up in the results, with the other jobs - * being displayed lower down in the results. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} - * if no value is specified. - * @param {google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo - * Controls over how job documents get ranked on top of existing relevance - * score (determined by API algorithm). - * @param {boolean} request.disableKeywordMatch - * This field is deprecated. Please use - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * going forward. - * - * To migrate, disable_keyword_match set to false maps to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, - * and disable_keyword_match set to true maps to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. - * If - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * is set, this field is ignored. - * - * Controls whether to disable exact keyword match on - * {@link protos.google.cloud.talent.v4.Job.title|Job.title}, - * {@link protos.google.cloud.talent.v4.Job.description|Job.description}, - * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}, - * {@link protos.google.cloud.talent.v4.Job.addresses|Job.addresses}, - * {@link protos.google.cloud.talent.v4.Job.qualifications|Job.qualifications}. When - * disable keyword match is turned off, a keyword match returns jobs that do - * not match given category filters when there are matching keywords. For - * example, for the query "program manager," a result is returned even if the - * job posting has the title "software developer," which doesn't fall into - * "program manager" ontology, but does have "program manager" appearing in - * its description. - * - * For queries like "cloud" that don't contain title or - * location specific ontology, jobs with "cloud" keyword matches are returned - * regardless of this flag's value. - * - * Use - * {@link protos.google.cloud.talent.v4.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} - * if company-specific globally matched custom field/attribute string values - * are needed. Enabling keyword match improves recall of subsequent search - * requests. - * - * Defaults to false. - * @param {google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode - * Controls what keyword match options to use. If both keyword_match_mode and - * disable_keyword_match are set, keyword_match_mode will take precedence. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} - * if no value is specified. - * @param {google.cloud.talent.v4.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] - * Optional. The relevance threshold of the search results. - * - * Default to Google defined threshold, leveraging a balance of - * precision and recall to deliver both highly accurate results and - * comprehensive coverage of relevant information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.SearchJobsResponse|SearchJobsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.search_jobs.js - * region_tag:jobs_v4_generated_JobService_SearchJobs_async - */ + /** + * Searches for jobs using the provided + * {@link protos.google.cloud.talent.v4.SearchJobsRequest|SearchJobsRequest}. + * + * This call constrains the + * {@link protos.google.cloud.talent.v4.Job.visibility|visibility} of jobs present in the + * database, and only returns jobs that the caller has permission to search + * against. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant to search within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {google.cloud.talent.v4.SearchJobsRequest.SearchMode} request.searchMode + * Mode of a search. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. + * @param {google.cloud.talent.v4.RequestMetadata} request.requestMetadata + * Required. The meta information collected about the job searcher, used to + * improve the search quality of the service. The identifiers (such as + * `user_id`) are provided by users, and must be unique and consistent. + * @param {google.cloud.talent.v4.JobQuery} request.jobQuery + * Query used to search against jobs, such as keyword, location filters, etc. + * @param {boolean} request.enableBroadening + * Controls whether to broaden the search when it produces sparse results. + * Broadened queries append results to the end of the matching results + * list. + * + * Defaults to false. + * @param {number[]} request.histogramQueries + * An expression specifies a histogram request against matching jobs. + * + * Expression syntax is an aggregation function call with histogram facets and + * other options. + * + * Available aggregation function calls are: + * * `count(string_histogram_facet)`: Count the number of matching entities, + * for each distinct attribute value. + * * `count(numeric_histogram_facet, list of buckets)`: Count the number of + * matching entities within each bucket. + * + * A maximum of 200 histogram buckets are supported. + * + * Data types: + * + * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. + * * String: string like "any string with backslash escape for quote(\")." + * * Number: whole number and floating point number like 10, -1 and -0.01. + * * List: list of elements with comma(,) separator surrounded by square + * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. + * + * Built-in constants: + * + * * MIN (minimum number similar to java Double.MIN_VALUE) + * * MAX (maximum number similar to java Double.MAX_VALUE) + * + * Built-in functions: + * + * * bucket(start, end[, label]): bucket built-in function creates a bucket + * with range of [start, end). Note that the end is exclusive, for example, + * bucket(1, MAX, "positive number") or bucket(1, 10). + * + * Job histogram facets: + * + * * company_display_name: histogram by + * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by + * {@link protos.google.cloud.talent.v4.Job.employment_types|Job.employment_types}, for + * example, + * "FULL_TIME", "PART_TIME". + * * company_size (DEPRECATED): histogram by + * {@link protos.google.cloud.talent.v4.CompanySize|CompanySize}, for example, "SMALL", + * "MEDIUM", "BIG". + * * publish_time_in_day: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in days. + * Must specify list of numeric buckets in spec. + * * publish_time_in_month: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in months. + * Must specify list of numeric buckets in spec. + * * publish_time_in_year: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in years. + * Must specify list of numeric buckets in spec. + * * degree_types: histogram by the + * {@link protos.google.cloud.talent.v4.Job.degree_types|Job.degree_types}, for example, + * "Bachelors", "Masters". + * * job_level: histogram by the + * {@link protos.google.cloud.talent.v4.Job.job_level|Job.job_level}, for example, "Entry + * Level". + * * country: histogram by the country code of jobs, for example, "US", "FR". + * * admin1: histogram by the admin1 code of jobs, which is a global + * placeholder referring to the state, province, or the particular term a + * country uses to define the geographic structure below the country level, + * for example, "CA", "IL". + * * city: histogram by a combination of the "city name, admin1 code". For + * example, "Mountain View, CA", "New York, NY". + * * admin1_country: histogram by a combination of the "admin1 code, country", + * for example, "CA, US", "IL, US". + * * city_coordinate: histogram by the city center's GPS coordinates (latitude + * and longitude), for example, 37.4038522,-122.0987765. Since the + * coordinates of a city center can change, customers may need to refresh + * them periodically. + * * locale: histogram by the + * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, for example, + * "en-US", + * "fr-FR". + * * language: histogram by the language subtag of the + * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, + * for example, "en", "fr". + * * category: histogram by the + * {@link protos.google.cloud.talent.v4.JobCategory|JobCategory}, for example, + * "COMPUTER_AND_IT", "HEALTHCARE". + * * base_compensation_unit: histogram by the + * {@link protos.google.cloud.talent.v4.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} + * of base salary, for example, "WEEKLY", "MONTHLY". + * * base_compensation: histogram by the base salary. Must specify list of + * numeric buckets to group results by. + * * annualized_base_compensation: histogram by the base annualized salary. + * Must specify list of numeric buckets to group results by. + * * annualized_total_compensation: histogram by the total annualized salary. + * Must specify list of numeric buckets to group results by. + * * string_custom_attribute: histogram by string + * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * string_custom_attribute["key1"]. + * * numeric_custom_attribute: histogram by numeric + * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to + * group results by. + * + * Example expressions: + * + * * `count(admin1)` + * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), + * bucket(100000, MAX)])` + * * `count(string_custom_attribute["some-string-custom-attribute"])` + * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], + * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` + * @param {google.cloud.talent.v4.JobView} request.jobView + * The desired job attributes returned for jobs in the search response. + * Defaults to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if + * no value is specified. + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the jobs deemed by the API as relevant) in search + * results. This field is only considered if + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.page_token|page_token} is unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * job, and 10 means to return from the 11th job. This can be used for + * pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.maxPageSize + * A limit on the number of jobs returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within + * search results. See + * {@link protos.google.cloud.talent.v4.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} + * for an explanation of how to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. Default is + * `"relevance desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. Relevance thresholding of query results is only available + * with this ordering. + * * `"posting_publish_time desc"`: By + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * descending. + * * `"posting_update_time desc"`: By + * {@link protos.google.cloud.talent.v4.Job.posting_update_time|Job.posting_update_time} + * descending. + * * `"title"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} ascending. + * * `"title desc"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} + * descending. + * * `"annualized_base_compensation"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_base_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"annualized_total_compensation"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_total_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"custom_ranking desc"`: By the relevance score adjusted to the + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} + * with weight factor assigned by + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} + * in descending order. + * * Location sorting: Use the special syntax to order jobs by distance:
+ * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
+ * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
+ * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by + * multiple locations. See details below.
+ * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by + * multiple locations. See details below.
+ * The string can have a maximum of 256 characters. When multiple distance + * centers are provided, a job that is close to any of the distance centers + * would have a high rank. When a job has multiple locations, the job + * location closest to one of the distance centers will be used. Jobs that + * don't have locations will be ranked at the bottom. Distance is calculated + * with a precision of 11.3 meters (37.4 feet). Diversification strategy is + * still applied unless explicitly disabled in + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.diversification_level|diversification_level}. + * @param {google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel} request.diversificationLevel + * Controls whether highly similar jobs are returned next to each other in + * the search results. Jobs are identified as highly similar based on + * their titles, job categories, and locations. Highly similar results are + * clustered so that only one representative job of the cluster is + * displayed to the job seeker higher up in the results, with the other jobs + * being displayed lower down in the results. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} + * if no value is specified. + * @param {google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo + * Controls over how job documents get ranked on top of existing relevance + * score (determined by API algorithm). + * @param {boolean} request.disableKeywordMatch + * This field is deprecated. Please use + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * going forward. + * + * To migrate, disable_keyword_match set to false maps to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, + * and disable_keyword_match set to true maps to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. + * If + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * is set, this field is ignored. + * + * Controls whether to disable exact keyword match on + * {@link protos.google.cloud.talent.v4.Job.title|Job.title}, + * {@link protos.google.cloud.talent.v4.Job.description|Job.description}, + * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}, + * {@link protos.google.cloud.talent.v4.Job.addresses|Job.addresses}, + * {@link protos.google.cloud.talent.v4.Job.qualifications|Job.qualifications}. When + * disable keyword match is turned off, a keyword match returns jobs that do + * not match given category filters when there are matching keywords. For + * example, for the query "program manager," a result is returned even if the + * job posting has the title "software developer," which doesn't fall into + * "program manager" ontology, but does have "program manager" appearing in + * its description. + * + * For queries like "cloud" that don't contain title or + * location specific ontology, jobs with "cloud" keyword matches are returned + * regardless of this flag's value. + * + * Use + * {@link protos.google.cloud.talent.v4.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} + * if company-specific globally matched custom field/attribute string values + * are needed. Enabling keyword match improves recall of subsequent search + * requests. + * + * Defaults to false. + * @param {google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode + * Controls what keyword match options to use. If both keyword_match_mode and + * disable_keyword_match are set, keyword_match_mode will take precedence. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} + * if no value is specified. + * @param {google.cloud.talent.v4.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] + * Optional. The relevance threshold of the search results. + * + * Default to Google defined threshold, leveraging a balance of + * precision and recall to deliver both highly accurate results and + * comprehensive coverage of relevant information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.SearchJobsResponse|SearchJobsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.search_jobs.js + * region_tag:jobs_v4_generated_JobService_SearchJobs_async + */ searchJobs( - request?: protos.google.cloud.talent.v4.ISearchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ISearchJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ] + >; searchJobs( - request: protos.google.cloud.talent.v4.ISearchJobsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ISearchJobsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobs( - request: protos.google.cloud.talent.v4.ISearchJobsRequest, - callback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ISearchJobsRequest, + callback: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobs( - request?: protos.google.cloud.talent.v4.ISearchJobsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.ISearchJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('searchJobs request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('searchJobs response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.searchJobs(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, - {}|undefined - ]) => { - this._log.info('searchJobs response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .searchJobs(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('searchJobs response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Searches for jobs using the provided - * {@link protos.google.cloud.talent.v4.SearchJobsRequest|SearchJobsRequest}. - * - * This API call is intended for the use case of targeting passive job - * seekers (for example, job seekers who have signed up to receive email - * alerts about potential job opportunities), it has different algorithmic - * adjustments that are designed to specifically target passive job seekers. - * - * This call constrains the - * {@link protos.google.cloud.talent.v4.Job.visibility|visibility} of jobs present in the - * database, and only returns jobs the caller has permission to search - * against. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant to search within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {google.cloud.talent.v4.SearchJobsRequest.SearchMode} request.searchMode - * Mode of a search. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. - * @param {google.cloud.talent.v4.RequestMetadata} request.requestMetadata - * Required. The meta information collected about the job searcher, used to - * improve the search quality of the service. The identifiers (such as - * `user_id`) are provided by users, and must be unique and consistent. - * @param {google.cloud.talent.v4.JobQuery} request.jobQuery - * Query used to search against jobs, such as keyword, location filters, etc. - * @param {boolean} request.enableBroadening - * Controls whether to broaden the search when it produces sparse results. - * Broadened queries append results to the end of the matching results - * list. - * - * Defaults to false. - * @param {number[]} request.histogramQueries - * An expression specifies a histogram request against matching jobs. - * - * Expression syntax is an aggregation function call with histogram facets and - * other options. - * - * Available aggregation function calls are: - * * `count(string_histogram_facet)`: Count the number of matching entities, - * for each distinct attribute value. - * * `count(numeric_histogram_facet, list of buckets)`: Count the number of - * matching entities within each bucket. - * - * A maximum of 200 histogram buckets are supported. - * - * Data types: - * - * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. - * * String: string like "any string with backslash escape for quote(\")." - * * Number: whole number and floating point number like 10, -1 and -0.01. - * * List: list of elements with comma(,) separator surrounded by square - * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. - * - * Built-in constants: - * - * * MIN (minimum number similar to java Double.MIN_VALUE) - * * MAX (maximum number similar to java Double.MAX_VALUE) - * - * Built-in functions: - * - * * bucket(start, end[, label]): bucket built-in function creates a bucket - * with range of [start, end). Note that the end is exclusive, for example, - * bucket(1, MAX, "positive number") or bucket(1, 10). - * - * Job histogram facets: - * - * * company_display_name: histogram by - * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}. - * * employment_type: histogram by - * {@link protos.google.cloud.talent.v4.Job.employment_types|Job.employment_types}, for - * example, - * "FULL_TIME", "PART_TIME". - * * company_size (DEPRECATED): histogram by - * {@link protos.google.cloud.talent.v4.CompanySize|CompanySize}, for example, "SMALL", - * "MEDIUM", "BIG". - * * publish_time_in_day: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in days. - * Must specify list of numeric buckets in spec. - * * publish_time_in_month: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in months. - * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * in years. - * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the - * {@link protos.google.cloud.talent.v4.Job.degree_types|Job.degree_types}, for example, - * "Bachelors", "Masters". - * * job_level: histogram by the - * {@link protos.google.cloud.talent.v4.Job.job_level|Job.job_level}, for example, "Entry - * Level". - * * country: histogram by the country code of jobs, for example, "US", "FR". - * * admin1: histogram by the admin1 code of jobs, which is a global - * placeholder referring to the state, province, or the particular term a - * country uses to define the geographic structure below the country level, - * for example, "CA", "IL". - * * city: histogram by a combination of the "city name, admin1 code". For - * example, "Mountain View, CA", "New York, NY". - * * admin1_country: histogram by a combination of the "admin1 code, country", - * for example, "CA, US", "IL, US". - * * city_coordinate: histogram by the city center's GPS coordinates (latitude - * and longitude), for example, 37.4038522,-122.0987765. Since the - * coordinates of a city center can change, customers may need to refresh - * them periodically. - * * locale: histogram by the - * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, for example, - * "en-US", - * "fr-FR". - * * language: histogram by the language subtag of the - * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, - * for example, "en", "fr". - * * category: histogram by the - * {@link protos.google.cloud.talent.v4.JobCategory|JobCategory}, for example, - * "COMPUTER_AND_IT", "HEALTHCARE". - * * base_compensation_unit: histogram by the - * {@link protos.google.cloud.talent.v4.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} - * of base salary, for example, "WEEKLY", "MONTHLY". - * * base_compensation: histogram by the base salary. Must specify list of - * numeric buckets to group results by. - * * annualized_base_compensation: histogram by the base annualized salary. - * Must specify list of numeric buckets to group results by. - * * annualized_total_compensation: histogram by the total annualized salary. - * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string - * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric - * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to - * group results by. - * - * Example expressions: - * - * * `count(admin1)` - * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), - * bucket(100000, MAX)])` - * * `count(string_custom_attribute["some-string-custom-attribute"])` - * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], - * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` - * @param {google.cloud.talent.v4.JobView} request.jobView - * The desired job attributes returned for jobs in the search response. - * Defaults to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if - * no value is specified. - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.page_token|page_token} is unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * job, and 10 means to return from the 11th job. This can be used for - * pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.maxPageSize - * A limit on the number of jobs returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within - * search results. See - * {@link protos.google.cloud.talent.v4.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} - * for an explanation of how to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. Default is - * `"relevance desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. Relevance thresholding of query results is only available - * with this ordering. - * * `"posting_publish_time desc"`: By - * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} - * descending. - * * `"posting_update_time desc"`: By - * {@link protos.google.cloud.talent.v4.Job.posting_update_time|Job.posting_update_time} - * descending. - * * `"title"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} ascending. - * * `"title desc"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} - * descending. - * * `"annualized_base_compensation"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_base_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"annualized_total_compensation"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_total_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"custom_ranking desc"`: By the relevance score adjusted to the - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} - * with weight factor assigned by - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} - * in descending order. - * * Location sorting: Use the special syntax to order jobs by distance:
- * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
- * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
- * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by - * multiple locations. See details below.
- * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by - * multiple locations. See details below.
- * The string can have a maximum of 256 characters. When multiple distance - * centers are provided, a job that is close to any of the distance centers - * would have a high rank. When a job has multiple locations, the job - * location closest to one of the distance centers will be used. Jobs that - * don't have locations will be ranked at the bottom. Distance is calculated - * with a precision of 11.3 meters (37.4 feet). Diversification strategy is - * still applied unless explicitly disabled in - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.diversification_level|diversification_level}. - * @param {google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel} request.diversificationLevel - * Controls whether highly similar jobs are returned next to each other in - * the search results. Jobs are identified as highly similar based on - * their titles, job categories, and locations. Highly similar results are - * clustered so that only one representative job of the cluster is - * displayed to the job seeker higher up in the results, with the other jobs - * being displayed lower down in the results. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} - * if no value is specified. - * @param {google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo - * Controls over how job documents get ranked on top of existing relevance - * score (determined by API algorithm). - * @param {boolean} request.disableKeywordMatch - * This field is deprecated. Please use - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * going forward. - * - * To migrate, disable_keyword_match set to false maps to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, - * and disable_keyword_match set to true maps to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. - * If - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * is set, this field is ignored. - * - * Controls whether to disable exact keyword match on - * {@link protos.google.cloud.talent.v4.Job.title|Job.title}, - * {@link protos.google.cloud.talent.v4.Job.description|Job.description}, - * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}, - * {@link protos.google.cloud.talent.v4.Job.addresses|Job.addresses}, - * {@link protos.google.cloud.talent.v4.Job.qualifications|Job.qualifications}. When - * disable keyword match is turned off, a keyword match returns jobs that do - * not match given category filters when there are matching keywords. For - * example, for the query "program manager," a result is returned even if the - * job posting has the title "software developer," which doesn't fall into - * "program manager" ontology, but does have "program manager" appearing in - * its description. - * - * For queries like "cloud" that don't contain title or - * location specific ontology, jobs with "cloud" keyword matches are returned - * regardless of this flag's value. - * - * Use - * {@link protos.google.cloud.talent.v4.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} - * if company-specific globally matched custom field/attribute string values - * are needed. Enabling keyword match improves recall of subsequent search - * requests. - * - * Defaults to false. - * @param {google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode - * Controls what keyword match options to use. If both keyword_match_mode and - * disable_keyword_match are set, keyword_match_mode will take precedence. - * - * Defaults to - * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} - * if no value is specified. - * @param {google.cloud.talent.v4.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] - * Optional. The relevance threshold of the search results. - * - * Default to Google defined threshold, leveraging a balance of - * precision and recall to deliver both highly accurate results and - * comprehensive coverage of relevant information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.SearchJobsResponse|SearchJobsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.search_jobs_for_alert.js - * region_tag:jobs_v4_generated_JobService_SearchJobsForAlert_async - */ + /** + * Searches for jobs using the provided + * {@link protos.google.cloud.talent.v4.SearchJobsRequest|SearchJobsRequest}. + * + * This API call is intended for the use case of targeting passive job + * seekers (for example, job seekers who have signed up to receive email + * alerts about potential job opportunities), it has different algorithmic + * adjustments that are designed to specifically target passive job seekers. + * + * This call constrains the + * {@link protos.google.cloud.talent.v4.Job.visibility|visibility} of jobs present in the + * database, and only returns jobs the caller has permission to search + * against. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant to search within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {google.cloud.talent.v4.SearchJobsRequest.SearchMode} request.searchMode + * Mode of a search. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. + * @param {google.cloud.talent.v4.RequestMetadata} request.requestMetadata + * Required. The meta information collected about the job searcher, used to + * improve the search quality of the service. The identifiers (such as + * `user_id`) are provided by users, and must be unique and consistent. + * @param {google.cloud.talent.v4.JobQuery} request.jobQuery + * Query used to search against jobs, such as keyword, location filters, etc. + * @param {boolean} request.enableBroadening + * Controls whether to broaden the search when it produces sparse results. + * Broadened queries append results to the end of the matching results + * list. + * + * Defaults to false. + * @param {number[]} request.histogramQueries + * An expression specifies a histogram request against matching jobs. + * + * Expression syntax is an aggregation function call with histogram facets and + * other options. + * + * Available aggregation function calls are: + * * `count(string_histogram_facet)`: Count the number of matching entities, + * for each distinct attribute value. + * * `count(numeric_histogram_facet, list of buckets)`: Count the number of + * matching entities within each bucket. + * + * A maximum of 200 histogram buckets are supported. + * + * Data types: + * + * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. + * * String: string like "any string with backslash escape for quote(\")." + * * Number: whole number and floating point number like 10, -1 and -0.01. + * * List: list of elements with comma(,) separator surrounded by square + * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. + * + * Built-in constants: + * + * * MIN (minimum number similar to java Double.MIN_VALUE) + * * MAX (maximum number similar to java Double.MAX_VALUE) + * + * Built-in functions: + * + * * bucket(start, end[, label]): bucket built-in function creates a bucket + * with range of [start, end). Note that the end is exclusive, for example, + * bucket(1, MAX, "positive number") or bucket(1, 10). + * + * Job histogram facets: + * + * * company_display_name: histogram by + * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by + * {@link protos.google.cloud.talent.v4.Job.employment_types|Job.employment_types}, for + * example, + * "FULL_TIME", "PART_TIME". + * * company_size (DEPRECATED): histogram by + * {@link protos.google.cloud.talent.v4.CompanySize|CompanySize}, for example, "SMALL", + * "MEDIUM", "BIG". + * * publish_time_in_day: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in days. + * Must specify list of numeric buckets in spec. + * * publish_time_in_month: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in months. + * Must specify list of numeric buckets in spec. + * * publish_time_in_year: histogram by the + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * in years. + * Must specify list of numeric buckets in spec. + * * degree_types: histogram by the + * {@link protos.google.cloud.talent.v4.Job.degree_types|Job.degree_types}, for example, + * "Bachelors", "Masters". + * * job_level: histogram by the + * {@link protos.google.cloud.talent.v4.Job.job_level|Job.job_level}, for example, "Entry + * Level". + * * country: histogram by the country code of jobs, for example, "US", "FR". + * * admin1: histogram by the admin1 code of jobs, which is a global + * placeholder referring to the state, province, or the particular term a + * country uses to define the geographic structure below the country level, + * for example, "CA", "IL". + * * city: histogram by a combination of the "city name, admin1 code". For + * example, "Mountain View, CA", "New York, NY". + * * admin1_country: histogram by a combination of the "admin1 code, country", + * for example, "CA, US", "IL, US". + * * city_coordinate: histogram by the city center's GPS coordinates (latitude + * and longitude), for example, 37.4038522,-122.0987765. Since the + * coordinates of a city center can change, customers may need to refresh + * them periodically. + * * locale: histogram by the + * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, for example, + * "en-US", + * "fr-FR". + * * language: histogram by the language subtag of the + * {@link protos.google.cloud.talent.v4.Job.language_code|Job.language_code}, + * for example, "en", "fr". + * * category: histogram by the + * {@link protos.google.cloud.talent.v4.JobCategory|JobCategory}, for example, + * "COMPUTER_AND_IT", "HEALTHCARE". + * * base_compensation_unit: histogram by the + * {@link protos.google.cloud.talent.v4.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} + * of base salary, for example, "WEEKLY", "MONTHLY". + * * base_compensation: histogram by the base salary. Must specify list of + * numeric buckets to group results by. + * * annualized_base_compensation: histogram by the base annualized salary. + * Must specify list of numeric buckets to group results by. + * * annualized_total_compensation: histogram by the total annualized salary. + * Must specify list of numeric buckets to group results by. + * * string_custom_attribute: histogram by string + * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * string_custom_attribute["key1"]. + * * numeric_custom_attribute: histogram by numeric + * {@link protos.google.cloud.talent.v4.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to + * group results by. + * + * Example expressions: + * + * * `count(admin1)` + * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), + * bucket(100000, MAX)])` + * * `count(string_custom_attribute["some-string-custom-attribute"])` + * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], + * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` + * @param {google.cloud.talent.v4.JobView} request.jobView + * The desired job attributes returned for jobs in the search response. + * Defaults to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} if + * no value is specified. + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the jobs deemed by the API as relevant) in search + * results. This field is only considered if + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.page_token|page_token} is unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * job, and 10 means to return from the 11th job. This can be used for + * pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.maxPageSize + * A limit on the number of jobs returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within + * search results. See + * {@link protos.google.cloud.talent.v4.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} + * for an explanation of how to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. Default is + * `"relevance desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. Relevance thresholding of query results is only available + * with this ordering. + * * `"posting_publish_time desc"`: By + * {@link protos.google.cloud.talent.v4.Job.posting_publish_time|Job.posting_publish_time} + * descending. + * * `"posting_update_time desc"`: By + * {@link protos.google.cloud.talent.v4.Job.posting_update_time|Job.posting_update_time} + * descending. + * * `"title"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} ascending. + * * `"title desc"`: By {@link protos.google.cloud.talent.v4.Job.title|Job.title} + * descending. + * * `"annualized_base_compensation"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_base_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"annualized_total_compensation"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_total_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"custom_ranking desc"`: By the relevance score adjusted to the + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} + * with weight factor assigned by + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} + * in descending order. + * * Location sorting: Use the special syntax to order jobs by distance:
+ * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
+ * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
+ * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by + * multiple locations. See details below.
+ * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by + * multiple locations. See details below.
+ * The string can have a maximum of 256 characters. When multiple distance + * centers are provided, a job that is close to any of the distance centers + * would have a high rank. When a job has multiple locations, the job + * location closest to one of the distance centers will be used. Jobs that + * don't have locations will be ranked at the bottom. Distance is calculated + * with a precision of 11.3 meters (37.4 feet). Diversification strategy is + * still applied unless explicitly disabled in + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.diversification_level|diversification_level}. + * @param {google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel} request.diversificationLevel + * Controls whether highly similar jobs are returned next to each other in + * the search results. Jobs are identified as highly similar based on + * their titles, job categories, and locations. Highly similar results are + * clustered so that only one representative job of the cluster is + * displayed to the job seeker higher up in the results, with the other jobs + * being displayed lower down in the results. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} + * if no value is specified. + * @param {google.cloud.talent.v4.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo + * Controls over how job documents get ranked on top of existing relevance + * score (determined by API algorithm). + * @param {boolean} request.disableKeywordMatch + * This field is deprecated. Please use + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * going forward. + * + * To migrate, disable_keyword_match set to false maps to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, + * and disable_keyword_match set to true maps to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. + * If + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * is set, this field is ignored. + * + * Controls whether to disable exact keyword match on + * {@link protos.google.cloud.talent.v4.Job.title|Job.title}, + * {@link protos.google.cloud.talent.v4.Job.description|Job.description}, + * {@link protos.google.cloud.talent.v4.Job.company_display_name|Job.company_display_name}, + * {@link protos.google.cloud.talent.v4.Job.addresses|Job.addresses}, + * {@link protos.google.cloud.talent.v4.Job.qualifications|Job.qualifications}. When + * disable keyword match is turned off, a keyword match returns jobs that do + * not match given category filters when there are matching keywords. For + * example, for the query "program manager," a result is returned even if the + * job posting has the title "software developer," which doesn't fall into + * "program manager" ontology, but does have "program manager" appearing in + * its description. + * + * For queries like "cloud" that don't contain title or + * location specific ontology, jobs with "cloud" keyword matches are returned + * regardless of this flag's value. + * + * Use + * {@link protos.google.cloud.talent.v4.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} + * if company-specific globally matched custom field/attribute string values + * are needed. Enabling keyword match improves recall of subsequent search + * requests. + * + * Defaults to false. + * @param {google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode + * Controls what keyword match options to use. If both keyword_match_mode and + * disable_keyword_match are set, keyword_match_mode will take precedence. + * + * Defaults to + * {@link protos.google.cloud.talent.v4.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} + * if no value is specified. + * @param {google.cloud.talent.v4.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] + * Optional. The relevance threshold of the search results. + * + * Default to Google defined threshold, leveraging a balance of + * precision and recall to deliver both highly accurate results and + * comprehensive coverage of relevant information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.SearchJobsResponse|SearchJobsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.search_jobs_for_alert.js + * region_tag:jobs_v4_generated_JobService_SearchJobsForAlert_async + */ searchJobsForAlert( - request?: protos.google.cloud.talent.v4.ISearchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ISearchJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ] + >; searchJobsForAlert( - request: protos.google.cloud.talent.v4.ISearchJobsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ISearchJobsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobsForAlert( - request: protos.google.cloud.talent.v4.ISearchJobsRequest, - callback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ISearchJobsRequest, + callback: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobsForAlert( - request?: protos.google.cloud.talent.v4.ISearchJobsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.ISearchJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('searchJobsForAlert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('searchJobsForAlert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.searchJobsForAlert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ISearchJobsResponse, - protos.google.cloud.talent.v4.ISearchJobsRequest|undefined, - {}|undefined - ]) => { - this._log.info('searchJobsForAlert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .searchJobsForAlert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ISearchJobsResponse, + protos.google.cloud.talent.v4.ISearchJobsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('searchJobsForAlert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Begins executing a batch create jobs operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {number[]} request.jobs - * Required. The jobs to be created. - * A maximum of 200 jobs can be created 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_create_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchCreateJobs_async - */ + /** + * Begins executing a batch create jobs operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {number[]} request.jobs + * Required. The jobs to be created. + * A maximum of 200 jobs can be created 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_create_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchCreateJobs_async + */ batchCreateJobs( - request?: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchCreateJobs( - request: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchCreateJobs( - request: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchCreateJobs( - request?: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.talent.v4.IBatchCreateJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchCreateJobs response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchCreateJobs request %j', request); - return this.innerApiCalls.batchCreateJobs(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchCreateJobs response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchCreateJobs(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchCreateJobs response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchCreateJobs()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_create_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchCreateJobs_async - */ - async checkBatchCreateJobsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchCreateJobs()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_create_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchCreateJobs_async + */ + async checkBatchCreateJobsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.talent.v4.BatchCreateJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + > + > { this._log.info('batchCreateJobs long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchCreateJobs, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchCreateJobs, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.talent.v4.BatchCreateJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + >; } -/** - * Begins executing a batch update jobs operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {number[]} request.jobs - * Required. The jobs to be updated. - * A maximum of 200 jobs can be updated in a batch. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. Be aware that it will - * also increase latency when checking the status of a batch operation. - * - * If {@link protos.google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask|update_mask} - * is provided, only the specified fields in {@link protos.google.cloud.talent.v4.Job|Job} - * are updated. Otherwise all the fields are updated. - * - * A field mask to restrict the fields that are updated. Only - * top level fields of {@link protos.google.cloud.talent.v4.Job|Job} are supported. - * - * If {@link protos.google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask|update_mask} - * is provided, The {@link protos.google.cloud.talent.v4.Job|Job} inside - * {@link protos.google.cloud.talent.v4.JobResult|JobResult} - * will only contains fields that is updated, plus the Id of the Job. - * Otherwise, {@link protos.google.cloud.talent.v4.Job|Job} will include all fields, - * which can yield a very large 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_update_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchUpdateJobs_async - */ + /** + * Begins executing a batch update jobs operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {number[]} request.jobs + * Required. The jobs to be updated. + * A maximum of 200 jobs can be updated in a batch. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. Be aware that it will + * also increase latency when checking the status of a batch operation. + * + * If {@link protos.google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask|update_mask} + * is provided, only the specified fields in {@link protos.google.cloud.talent.v4.Job|Job} + * are updated. Otherwise all the fields are updated. + * + * A field mask to restrict the fields that are updated. Only + * top level fields of {@link protos.google.cloud.talent.v4.Job|Job} are supported. + * + * If {@link protos.google.cloud.talent.v4.BatchUpdateJobsRequest.update_mask|update_mask} + * is provided, The {@link protos.google.cloud.talent.v4.Job|Job} inside + * {@link protos.google.cloud.talent.v4.JobResult|JobResult} + * will only contains fields that is updated, plus the Id of the Job. + * Otherwise, {@link protos.google.cloud.talent.v4.Job|Job} will include all fields, + * which can yield a very large 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_update_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchUpdateJobs_async + */ batchUpdateJobs( - request?: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchUpdateJobs( - request: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchUpdateJobs( - request: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchUpdateJobs( - request?: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.talent.v4.IBatchUpdateJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchUpdateJobs response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchUpdateJobs request %j', request); - return this.innerApiCalls.batchUpdateJobs(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchUpdateJobs response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchUpdateJobs(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchUpdateJobs response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchUpdateJobs()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_update_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchUpdateJobs_async - */ - async checkBatchUpdateJobsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchUpdateJobs()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_update_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchUpdateJobs_async + */ + async checkBatchUpdateJobsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.talent.v4.BatchUpdateJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + > + > { this._log.info('batchUpdateJobs long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchUpdateJobs, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchUpdateJobs, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.talent.v4.BatchUpdateJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + >; } -/** - * Begins executing a batch delete jobs operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * - * The parent of all of the jobs specified in `names` must match this field. - * @param {string[]} request.names - * The names of the jobs to delete. - * - * The format is "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". - * For example, "projects/foo/tenants/bar/jobs/baz". - * - * A maximum of 200 jobs can be deleted 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 - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_delete_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchDeleteJobs_async - */ + /** + * Begins executing a batch delete jobs operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * + * The parent of all of the jobs specified in `names` must match this field. + * @param {string[]} request.names + * The names of the jobs to delete. + * + * The format is "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". + * For example, "projects/foo/tenants/bar/jobs/baz". + * + * A maximum of 200 jobs can be deleted 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 + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_delete_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchDeleteJobs_async + */ batchDeleteJobs( - request?: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchDeleteJobs( - request: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchDeleteJobs( - request: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchDeleteJobs( - request?: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.talent.v4.IBatchDeleteJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchDeleteJobs response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchDeleteJobs request %j', request); - return this.innerApiCalls.batchDeleteJobs(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchDeleteJobs response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchDeleteJobs(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchDeleteJobs response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchDeleteJobs()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4/job_service.batch_delete_jobs.js - * region_tag:jobs_v4_generated_JobService_BatchDeleteJobs_async - */ - async checkBatchDeleteJobsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchDeleteJobs()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4/job_service.batch_delete_jobs.js + * region_tag:jobs_v4_generated_JobService_BatchDeleteJobs_async + */ + async checkBatchDeleteJobsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.talent.v4.BatchDeleteJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + > + > { this._log.info('batchDeleteJobs long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchDeleteJobs, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchDeleteJobs, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.talent.v4.BatchDeleteJobsResponse, + protos.google.cloud.talent.v4.BatchOperationMetadata + >; } - /** - * Lists jobs by filter. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no - * value is specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.talent.v4.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 jobs by filter. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no + * value is specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.talent.v4.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobs( - request?: protos.google.cloud.talent.v4.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.IJob[], - protos.google.cloud.talent.v4.IListJobsRequest|null, - protos.google.cloud.talent.v4.IListJobsResponse - ]>; + request?: protos.google.cloud.talent.v4.IListJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob[], + protos.google.cloud.talent.v4.IListJobsRequest | null, + protos.google.cloud.talent.v4.IListJobsResponse, + ] + >; listJobs( - request: protos.google.cloud.talent.v4.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListJobsRequest, - protos.google.cloud.talent.v4.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4.IJob>): void; + request: protos.google.cloud.talent.v4.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListJobsRequest, + protos.google.cloud.talent.v4.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4.IJob + >, + ): void; listJobs( - request: protos.google.cloud.talent.v4.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListJobsRequest, - protos.google.cloud.talent.v4.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4.IJob>): void; + request: protos.google.cloud.talent.v4.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListJobsRequest, + protos.google.cloud.talent.v4.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4.IJob + >, + ): void; listJobs( - request?: protos.google.cloud.talent.v4.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.talent.v4.IListJobsRequest, - protos.google.cloud.talent.v4.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4.IJob>, - callback?: PaginationCallback< + request?: protos.google.cloud.talent.v4.IListJobsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4.IListJobsRequest, - protos.google.cloud.talent.v4.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4.IJob>): - Promise<[ - protos.google.cloud.talent.v4.IJob[], - protos.google.cloud.talent.v4.IListJobsRequest|null, - protos.google.cloud.talent.v4.IListJobsResponse - ]>|void { + protos.google.cloud.talent.v4.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4.IJob + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4.IListJobsRequest, + protos.google.cloud.talent.v4.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4.IJob + >, + ): Promise< + [ + protos.google.cloud.talent.v4.IJob[], + protos.google.cloud.talent.v4.IListJobsRequest | null, + protos.google.cloud.talent.v4.IListJobsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IListJobsRequest, - protos.google.cloud.talent.v4.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4.IJob>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4.IListJobsRequest, + protos.google.cloud.talent.v4.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4.IJob + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listJobs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2046,187 +2505,191 @@ export class JobServiceClient { this._log.info('listJobs request %j', request); return this.innerApiCalls .listJobs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4.IJob[], - protos.google.cloud.talent.v4.IListJobsRequest|null, - protos.google.cloud.talent.v4.IListJobsResponse - ]) => { - this._log.info('listJobs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4.IJob[], + protos.google.cloud.talent.v4.IListJobsRequest | null, + protos.google.cloud.talent.v4.IListJobsResponse, + ]) => { + this._log.info('listJobs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listJobs`, 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 tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no - * value is specified. - * @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.talent.v4.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 `listJobs`, 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 tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no + * value is specified. + * @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.talent.v4.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobsStream( - request?: protos.google.cloud.talent.v4.IListJobsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs stream %j', request); return this.descriptors.page.listJobs.createStream( this.innerApiCalls.listJobs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listJobs`, 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 tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenants/bar". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no - * value is specified. - * @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.talent.v4.Job|Job}. 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/v4/job_service.list_jobs.js - * region_tag:jobs_v4_generated_JobService_ListJobs_async - */ + /** + * Equivalent to `listJobs`, 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 tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenants/bar". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4.ListJobsRequest.job_view|job_view} is set to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} if no + * value is specified. + * @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.talent.v4.Job|Job}. 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/v4/job_service.list_jobs.js + * region_tag:jobs_v4_generated_JobService_ListJobs_async + */ listJobsAsync( - request?: protos.google.cloud.talent.v4.IListJobsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs iterate %j', request); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + /** * 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. @@ -2269,22 +2732,22 @@ export class JobServiceClient { 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); } /** @@ -2319,15 +2782,15 @@ export class JobServiceClient { */ 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); } /** @@ -2361,7 +2824,7 @@ export class JobServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2374,25 +2837,24 @@ export class JobServiceClient { 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 @@ -2431,22 +2893,22 @@ export class JobServiceClient { 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); } @@ -2462,7 +2924,7 @@ export class JobServiceClient { * @param {string} company * @returns {string} Resource name string. */ - companyPath(project:string,tenant:string,company:string) { + companyPath(project: string, tenant: string, company: string) { return this.pathTemplates.companyPathTemplate.render({ project: project, tenant: tenant, @@ -2511,7 +2973,7 @@ export class JobServiceClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,tenant:string,job:string) { + jobPath(project: string, tenant: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, tenant: tenant, @@ -2558,7 +3020,7 @@ export class JobServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2582,7 +3044,7 @@ export class JobServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -2619,7 +3081,7 @@ export class JobServiceClient { */ close(): Promise { if (this.jobServiceStub && !this._terminated) { - return this.jobServiceStub.then(stub => { + return this.jobServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2628,4 +3090,4 @@ export class JobServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4/tenant_service_client.ts b/packages/google-cloud-talent/src/v4/tenant_service_client.ts index cb2eb9c7c69a..77d720271e87 100644 --- a/packages/google-cloud-talent/src/v4/tenant_service_client.ts +++ b/packages/google-cloud-talent/src/v4/tenant_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class TenantServiceClient { 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('talent'); @@ -57,9 +64,9 @@ export class TenantServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - tenantServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + tenantServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of TenantServiceClient. @@ -100,21 +107,42 @@ export class TenantServiceClient { * const client = new TenantServiceClient({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 TenantServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +167,7 @@ export class TenantServiceClient { 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; @@ -153,10 +181,7 @@ export class TenantServiceClient { } // 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 { @@ -178,16 +203,16 @@ export class TenantServiceClient { // Create useful helper objects for these. this.pathTemplates = { companyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), jobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -195,14 +220,20 @@ export class TenantServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTenants: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tenants') + listTenants: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tenants', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4.TenantService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4.TenantService', + 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 @@ -233,37 +264,46 @@ export class TenantServiceClient { // Put together the "service stub" for // google.cloud.talent.v4.TenantService. this.tenantServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4.TenantService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4.TenantService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4.TenantService, - 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 tenantServiceStubMethods = - ['createTenant', 'getTenant', 'updateTenant', 'deleteTenant', 'listTenants']; + const tenantServiceStubMethods = [ + 'createTenant', + 'getTenant', + 'updateTenant', + 'deleteTenant', + 'listTenants', + ]; for (const methodName of tenantServiceStubMethods) { const callPromise = this.tenantServiceStub.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; @@ -278,8 +318,14 @@ export class TenantServiceClient { * @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 'jobs.googleapis.com'; } @@ -290,8 +336,14 @@ export class TenantServiceClient { * @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 'jobs.googleapis.com'; } @@ -324,7 +376,7 @@ export class TenantServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -334,8 +386,9 @@ export class TenantServiceClient { * 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; @@ -346,490 +399,625 @@ export class TenantServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new tenant entity. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {google.cloud.talent.v4.Tenant} request.tenant - * Required. The tenant 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 {@link protos.google.cloud.talent.v4.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/tenant_service.create_tenant.js - * region_tag:jobs_v4_generated_TenantService_CreateTenant_async - */ + /** + * Creates a new tenant entity. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {google.cloud.talent.v4.Tenant} request.tenant + * Required. The tenant 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 {@link protos.google.cloud.talent.v4.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/tenant_service.create_tenant.js + * region_tag:jobs_v4_generated_TenantService_CreateTenant_async + */ createTenant( - request?: protos.google.cloud.talent.v4.ICreateTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.ICreateTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | undefined, + {} | undefined, + ] + >; createTenant( - request: protos.google.cloud.talent.v4.ICreateTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; createTenant( - request: protos.google.cloud.talent.v4.ICreateTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.ICreateTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; createTenant( - request?: protos.google.cloud.talent.v4.ICreateTenantRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4.ICreateTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.ICreateTenantRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.ICreateTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('createTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.ICreateTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the tenant to be retrieved. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/tenant_service.get_tenant.js - * region_tag:jobs_v4_generated_TenantService_GetTenant_async - */ + /** + * Retrieves specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the tenant to be retrieved. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/tenant_service.get_tenant.js + * region_tag:jobs_v4_generated_TenantService_GetTenant_async + */ getTenant( - request?: protos.google.cloud.talent.v4.IGetTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IGetTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | undefined, + {} | undefined, + ] + >; getTenant( - request: protos.google.cloud.talent.v4.IGetTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; getTenant( - request: protos.google.cloud.talent.v4.IGetTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IGetTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; getTenant( - request?: protos.google.cloud.talent.v4.IGetTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IGetTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IGetTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IGetTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4.Tenant} request.tenant - * Required. The tenant resource to replace the current resource in the - * system. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If {@link protos.google.cloud.talent.v4.UpdateTenantRequest.update_mask|update_mask} is - * provided, only the specified fields in - * {@link protos.google.cloud.talent.v4.UpdateTenantRequest.tenant|tenant} are updated. - * Otherwise all the fields are updated. - * - * A field mask to specify the tenant fields to be updated. Only - * top level fields of {@link protos.google.cloud.talent.v4.Tenant|Tenant} are 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 {@link protos.google.cloud.talent.v4.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4/tenant_service.update_tenant.js - * region_tag:jobs_v4_generated_TenantService_UpdateTenant_async - */ + /** + * Updates specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4.Tenant} request.tenant + * Required. The tenant resource to replace the current resource in the + * system. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If {@link protos.google.cloud.talent.v4.UpdateTenantRequest.update_mask|update_mask} is + * provided, only the specified fields in + * {@link protos.google.cloud.talent.v4.UpdateTenantRequest.tenant|tenant} are updated. + * Otherwise all the fields are updated. + * + * A field mask to specify the tenant fields to be updated. Only + * top level fields of {@link protos.google.cloud.talent.v4.Tenant|Tenant} are 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 {@link protos.google.cloud.talent.v4.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4/tenant_service.update_tenant.js + * region_tag:jobs_v4_generated_TenantService_UpdateTenant_async + */ updateTenant( - request?: protos.google.cloud.talent.v4.IUpdateTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IUpdateTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | undefined, + {} | undefined, + ] + >; updateTenant( - request: protos.google.cloud.talent.v4.IUpdateTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; updateTenant( - request: protos.google.cloud.talent.v4.IUpdateTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IUpdateTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; updateTenant( - request?: protos.google.cloud.talent.v4.IUpdateTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IUpdateTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IUpdateTenantRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tenant.name': request.tenant!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'tenant.name': request.tenant!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4.ITenant, - protos.google.cloud.talent.v4.IUpdateTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4.ITenant, + protos.google.cloud.talent.v4.IUpdateTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the tenant to be deleted. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/tenant_service.delete_tenant.js - * region_tag:jobs_v4_generated_TenantService_DeleteTenant_async - */ + /** + * Deletes specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the tenant to be deleted. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4/tenant_service.delete_tenant.js + * region_tag:jobs_v4_generated_TenantService_DeleteTenant_async + */ deleteTenant( - request?: protos.google.cloud.talent.v4.IDeleteTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4.IDeleteTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | undefined, + {} | undefined, + ] + >; deleteTenant( - request: protos.google.cloud.talent.v4.IDeleteTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTenant( - request: protos.google.cloud.talent.v4.IDeleteTenantRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4.IDeleteTenantRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTenant( - request?: protos.google.cloud.talent.v4.IDeleteTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4.IDeleteTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4.IDeleteTenantRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTenant request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4.IDeleteTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4.IDeleteTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all tenants associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number 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 Array of {@link protos.google.cloud.talent.v4.Tenant|Tenant}. - * 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 `listTenantsAsync()` - * method described below for async iteration which you can stop as 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 tenants associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number 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 Array of {@link protos.google.cloud.talent.v4.Tenant|Tenant}. + * 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 `listTenantsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTenants( - request?: protos.google.cloud.talent.v4.IListTenantsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4.ITenant[], - protos.google.cloud.talent.v4.IListTenantsRequest|null, - protos.google.cloud.talent.v4.IListTenantsResponse - ]>; + request?: protos.google.cloud.talent.v4.IListTenantsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant[], + protos.google.cloud.talent.v4.IListTenantsRequest | null, + protos.google.cloud.talent.v4.IListTenantsResponse, + ] + >; listTenants( - request: protos.google.cloud.talent.v4.IListTenantsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListTenantsRequest, - protos.google.cloud.talent.v4.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4.ITenant>): void; + request: protos.google.cloud.talent.v4.IListTenantsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListTenantsRequest, + protos.google.cloud.talent.v4.IListTenantsResponse | null | undefined, + protos.google.cloud.talent.v4.ITenant + >, + ): void; listTenants( - request: protos.google.cloud.talent.v4.IListTenantsRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4.IListTenantsRequest, - protos.google.cloud.talent.v4.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4.ITenant>): void; + request: protos.google.cloud.talent.v4.IListTenantsRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4.IListTenantsRequest, + protos.google.cloud.talent.v4.IListTenantsResponse | null | undefined, + protos.google.cloud.talent.v4.ITenant + >, + ): void; listTenants( - request?: protos.google.cloud.talent.v4.IListTenantsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.talent.v4.IListTenantsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4.IListTenantsRequest, - protos.google.cloud.talent.v4.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4.ITenant>, - callback?: PaginationCallback< - protos.google.cloud.talent.v4.IListTenantsRequest, - protos.google.cloud.talent.v4.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4.ITenant>): - Promise<[ - protos.google.cloud.talent.v4.ITenant[], - protos.google.cloud.talent.v4.IListTenantsRequest|null, - protos.google.cloud.talent.v4.IListTenantsResponse - ]>|void { + protos.google.cloud.talent.v4.IListTenantsResponse | null | undefined, + protos.google.cloud.talent.v4.ITenant + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4.IListTenantsRequest, + protos.google.cloud.talent.v4.IListTenantsResponse | null | undefined, + protos.google.cloud.talent.v4.ITenant + >, + ): Promise< + [ + protos.google.cloud.talent.v4.ITenant[], + protos.google.cloud.talent.v4.IListTenantsRequest | null, + protos.google.cloud.talent.v4.IListTenantsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4.IListTenantsRequest, - protos.google.cloud.talent.v4.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4.ITenant>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4.IListTenantsRequest, + protos.google.cloud.talent.v4.IListTenantsResponse | null | undefined, + protos.google.cloud.talent.v4.ITenant + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTenants values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -838,114 +1026,118 @@ export class TenantServiceClient { this._log.info('listTenants request %j', request); return this.innerApiCalls .listTenants(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4.ITenant[], - protos.google.cloud.talent.v4.IListTenantsRequest|null, - protos.google.cloud.talent.v4.IListTenantsResponse - ]) => { - this._log.info('listTenants values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4.ITenant[], + protos.google.cloud.talent.v4.IListTenantsRequest | null, + protos.google.cloud.talent.v4.IListTenantsResponse, + ]) => { + this._log.info('listTenants values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTenants`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @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.talent.v4.Tenant|Tenant} 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 `listTenantsAsync()` - * method described below for async iteration which you can stop as 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 `listTenants`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @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.talent.v4.Tenant|Tenant} 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 `listTenantsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTenantsStream( - request?: protos.google.cloud.talent.v4.IListTenantsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4.IListTenantsRequest, + 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['listTenants']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTenants stream %j', request); return this.descriptors.page.listTenants.createStream( this.innerApiCalls.listTenants as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTenants`, 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. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @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.talent.v4.Tenant|Tenant}. 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/v4/tenant_service.list_tenants.js - * region_tag:jobs_v4_generated_TenantService_ListTenants_async - */ + /** + * Equivalent to `listTenants`, 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. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @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.talent.v4.Tenant|Tenant}. 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/v4/tenant_service.list_tenants.js + * region_tag:jobs_v4_generated_TenantService_ListTenants_async + */ listTenantsAsync( - request?: protos.google.cloud.talent.v4.IListTenantsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4.IListTenantsRequest, + 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['listTenants']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTenants iterate %j', request); return this.descriptors.page.listTenants.asyncIterate( this.innerApiCalls['listTenants'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -960,7 +1152,7 @@ export class TenantServiceClient { * @param {string} company * @returns {string} Resource name string. */ - companyPath(project:string,tenant:string,company:string) { + companyPath(project: string, tenant: string, company: string) { return this.pathTemplates.companyPathTemplate.render({ project: project, tenant: tenant, @@ -1009,7 +1201,7 @@ export class TenantServiceClient { * @param {string} job * @returns {string} Resource name string. */ - jobPath(project:string,tenant:string,job:string) { + jobPath(project: string, tenant: string, job: string) { return this.pathTemplates.jobPathTemplate.render({ project: project, tenant: tenant, @@ -1056,7 +1248,7 @@ export class TenantServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1080,7 +1272,7 @@ export class TenantServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -1117,7 +1309,7 @@ export class TenantServiceClient { */ close(): Promise { if (this.tenantServiceStub && !this._terminated) { - return this.tenantServiceStub.then(stub => { + return this.tenantServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1125,4 +1317,4 @@ export class TenantServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4beta1/company_service_client.ts b/packages/google-cloud-talent/src/v4beta1/company_service_client.ts index fcbf146331dd..ae946804e356 100644 --- a/packages/google-cloud-talent/src/v4beta1/company_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/company_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class CompanyServiceClient { 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('talent'); @@ -57,9 +64,9 @@ export class CompanyServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - companyServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + companyServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CompanyServiceClient. @@ -100,21 +107,42 @@ export class CompanyServiceClient { * const client = new CompanyServiceClient({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 CompanyServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +167,7 @@ export class CompanyServiceClient { 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; @@ -153,10 +181,7 @@ export class CompanyServiceClient { } // 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 { @@ -178,22 +203,22 @@ export class CompanyServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/companies/{company}' + 'projects/{project}/companies/{company}', ), projectJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/jobs/{job}' + 'projects/{project}/jobs/{job}', ), projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -201,14 +226,20 @@ export class CompanyServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listCompanies: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'companies') + listCompanies: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'companies', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4beta1.CompanyService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4beta1.CompanyService', + 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 @@ -239,37 +270,46 @@ export class CompanyServiceClient { // Put together the "service stub" for // google.cloud.talent.v4beta1.CompanyService. this.companyServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4beta1.CompanyService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4beta1.CompanyService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4beta1.CompanyService, - 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 companyServiceStubMethods = - ['createCompany', 'getCompany', 'updateCompany', 'deleteCompany', 'listCompanies']; + const companyServiceStubMethods = [ + 'createCompany', + 'getCompany', + 'updateCompany', + 'deleteCompany', + 'listCompanies', + ]; for (const methodName of companyServiceStubMethods) { const callPromise = this.companyServiceStub.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; @@ -284,8 +324,14 @@ export class CompanyServiceClient { * @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 'jobs.googleapis.com'; } @@ -296,8 +342,14 @@ export class CompanyServiceClient { * @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 'jobs.googleapis.com'; } @@ -330,7 +382,7 @@ export class CompanyServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -340,8 +392,9 @@ export class CompanyServiceClient { * 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; @@ -352,513 +405,692 @@ export class CompanyServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new company entity. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created, for example, "projects/foo". - * @param {google.cloud.talent.v4beta1.Company} request.company - * Required. The company 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 {@link protos.google.cloud.talent.v4beta1.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/company_service.create_company.js - * region_tag:jobs_v4beta1_generated_CompanyService_CreateCompany_async - */ + /** + * Creates a new company entity. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created, for example, "projects/foo". + * @param {google.cloud.talent.v4beta1.Company} request.company + * Required. The company 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 {@link protos.google.cloud.talent.v4beta1.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/company_service.create_company.js + * region_tag:jobs_v4beta1_generated_CompanyService_CreateCompany_async + */ createCompany( - request?: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.ICreateCompanyRequest | undefined, + {} | undefined, + ] + >; createCompany( - request: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCompany( - request: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createCompany( - request?: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.ICreateCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.ICreateCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.ICreateCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.ICreateCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('createCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.ICreateCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves specified company. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the company to be retrieved. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/api-test-project/tenants/foo/companies/bar". - * - * If tenant id is unspecified, the default tenant is used, for - * example, "projects/api-test-project/companies/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/company_service.get_company.js - * region_tag:jobs_v4beta1_generated_CompanyService_GetCompany_async - */ + /** + * Retrieves specified company. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the company to be retrieved. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/api-test-project/tenants/foo/companies/bar". + * + * If tenant id is unspecified, the default tenant is used, for + * example, "projects/api-test-project/companies/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/company_service.get_company.js + * region_tag:jobs_v4beta1_generated_CompanyService_GetCompany_async + */ getCompany( - request?: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | undefined, + {} | undefined, + ] + >; getCompany( - request: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCompany( - request: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): void; getCompany( - request?: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IGetCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IGetCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.IGetCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IGetCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('getCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IGetCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified company. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4beta1.Company} request.company - * Required. The company resource to replace the current resource in the - * system. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If - * {@link protos.google.cloud.talent.v4beta1.UpdateCompanyRequest.update_mask|update_mask} - * is provided, only the specified fields in - * {@link protos.google.cloud.talent.v4beta1.UpdateCompanyRequest.company|company} are - * updated. Otherwise all the fields are updated. - * - * A field mask to specify the company fields to be updated. Only - * top level fields of {@link protos.google.cloud.talent.v4beta1.Company|Company} are - * 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 {@link protos.google.cloud.talent.v4beta1.Company|Company}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/company_service.update_company.js - * region_tag:jobs_v4beta1_generated_CompanyService_UpdateCompany_async - */ + /** + * Updates specified company. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4beta1.Company} request.company + * Required. The company resource to replace the current resource in the + * system. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If + * {@link protos.google.cloud.talent.v4beta1.UpdateCompanyRequest.update_mask|update_mask} + * is provided, only the specified fields in + * {@link protos.google.cloud.talent.v4beta1.UpdateCompanyRequest.company|company} are + * updated. Otherwise all the fields are updated. + * + * A field mask to specify the company fields to be updated. Only + * top level fields of {@link protos.google.cloud.talent.v4beta1.Company|Company} are + * 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 {@link protos.google.cloud.talent.v4beta1.Company|Company}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/company_service.update_company.js + * region_tag:jobs_v4beta1_generated_CompanyService_UpdateCompany_async + */ updateCompany( - request?: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest | undefined, + {} | undefined, + ] + >; updateCompany( - request: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCompany( - request: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateCompany( - request?: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'company.name': request.company!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'company.name': request.company!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateCompany request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ICompany, + | protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ICompany, - protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ICompany, + protos.google.cloud.talent.v4beta1.IUpdateCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified company. - * Prerequisite: The company has no jobs associated with it. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the company to be deleted. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/foo/tenants/bar/companies/baz". - * - * If tenant id is unspecified, the default tenant is used, for - * example, "projects/foo/companies/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/company_service.delete_company.js - * region_tag:jobs_v4beta1_generated_CompanyService_DeleteCompany_async - */ + /** + * Deletes specified company. + * Prerequisite: The company has no jobs associated with it. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the company to be deleted. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/foo/tenants/bar/companies/baz". + * + * If tenant id is unspecified, the default tenant is used, for + * example, "projects/foo/companies/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/company_service.delete_company.js + * region_tag:jobs_v4beta1_generated_CompanyService_DeleteCompany_async + */ deleteCompany( - request?: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest | undefined, + {} | undefined, + ] + >; deleteCompany( - request: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCompany( - request: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteCompany( - request?: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteCompany request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteCompany response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteCompany(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteCompany response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteCompany(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteCompanyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteCompany response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all companies associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". - * - * If tenant id is unspecified, the default tenant will be used, for - * example, "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company}. - * 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 `listCompaniesAsync()` - * method described below for async iteration which you can stop as 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 companies associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". + * + * If tenant id is unspecified, the default tenant will be used, for + * example, "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company}. + * 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 `listCompaniesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCompanies( - request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany[], - protos.google.cloud.talent.v4beta1.IListCompaniesRequest|null, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse - ]>; + request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany[], + protos.google.cloud.talent.v4beta1.IListCompaniesRequest | null, + protos.google.cloud.talent.v4beta1.IListCompaniesResponse, + ] + >; listCompanies( - request: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ICompany>): void; + request: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + | protos.google.cloud.talent.v4beta1.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ICompany + >, + ): void; listCompanies( - request: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ICompany>): void; + request: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + | protos.google.cloud.talent.v4beta1.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ICompany + >, + ): void; listCompanies( - request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ICompany>, - callback?: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ICompany>): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompany[], - protos.google.cloud.talent.v4beta1.IListCompaniesRequest|null, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse - ]>|void { + | protos.google.cloud.talent.v4beta1.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ICompany + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + | protos.google.cloud.talent.v4beta1.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ICompany + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompany[], + protos.google.cloud.talent.v4beta1.IListCompaniesRequest | null, + protos.google.cloud.talent.v4beta1.IListCompaniesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4beta1.IListCompaniesRequest, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ICompany>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + | protos.google.cloud.talent.v4beta1.IListCompaniesResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ICompany + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listCompanies values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -867,136 +1099,140 @@ export class CompanyServiceClient { this._log.info('listCompanies request %j', request); return this.innerApiCalls .listCompanies(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4beta1.ICompany[], - protos.google.cloud.talent.v4beta1.IListCompaniesRequest|null, - protos.google.cloud.talent.v4beta1.IListCompaniesResponse - ]) => { - this._log.info('listCompanies values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4beta1.ICompany[], + protos.google.cloud.talent.v4beta1.IListCompaniesRequest | null, + protos.google.cloud.talent.v4beta1.IListCompaniesResponse, + ]) => { + this._log.info('listCompanies values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listCompanies`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". - * - * If tenant id is unspecified, the default tenant will be used, for - * example, "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company} 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 `listCompaniesAsync()` - * method described below for async iteration which you can stop as 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 `listCompanies`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". + * + * If tenant id is unspecified, the default tenant will be used, for + * example, "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company} 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 `listCompaniesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listCompaniesStream( - request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + 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['listCompanies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCompanies stream %j', request); return this.descriptors.page.listCompanies.createStream( this.innerApiCalls.listCompanies as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listCompanies`, 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. Resource name of the tenant under which the company is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". - * - * If tenant id is unspecified, the default tenant will be used, for - * example, "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of companies to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @param {boolean} request.requireOpenJobs - * Set to true if the companies requested must have open jobs. - * - * Defaults to false. - * - * If true, at most - * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of - * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company}. 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/v4beta1/company_service.list_companies.js - * region_tag:jobs_v4beta1_generated_CompanyService_ListCompanies_async - */ + /** + * Equivalent to `listCompanies`, 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. Resource name of the tenant under which the company is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". + * + * If tenant id is unspecified, the default tenant will be used, for + * example, "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of companies to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @param {boolean} request.requireOpenJobs + * Set to true if the companies requested must have open jobs. + * + * Defaults to false. + * + * If true, at most + * {@link protos.google.cloud.talent.v4beta1.ListCompaniesRequest.page_size|page_size} of + * companies are fetched, among which only those with open jobs are 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.talent.v4beta1.Company|Company}. 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/v4beta1/company_service.list_companies.js + * region_tag:jobs_v4beta1_generated_CompanyService_ListCompanies_async + */ listCompaniesAsync( - request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4beta1.IListCompaniesRequest, + 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['listCompanies']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listCompanies iterate %j', request); return this.descriptors.page.listCompanies.asyncIterate( this.innerApiCalls['listCompanies'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -1009,7 +1245,7 @@ export class CompanyServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -1033,7 +1269,7 @@ export class CompanyServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectCompanyPath(project:string,company:string) { + projectCompanyPath(project: string, company: string) { return this.pathTemplates.projectCompanyPathTemplate.render({ project: project, company: company, @@ -1048,7 +1284,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).project; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).project; } /** @@ -1059,7 +1297,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).company; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).company; } /** @@ -1069,7 +1309,7 @@ export class CompanyServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectJobPath(project:string,job:string) { + projectJobPath(project: string, job: string) { return this.pathTemplates.projectJobPathTemplate.render({ project: project, job: job, @@ -1084,7 +1324,8 @@ export class CompanyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectJobName(projectJobName: string) { - return this.pathTemplates.projectJobPathTemplate.match(projectJobName).project; + return this.pathTemplates.projectJobPathTemplate.match(projectJobName) + .project; } /** @@ -1106,7 +1347,7 @@ export class CompanyServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectTenantCompanyPath(project:string,tenant:string,company:string) { + projectTenantCompanyPath(project: string, tenant: string, company: string) { return this.pathTemplates.projectTenantCompanyPathTemplate.render({ project: project, tenant: tenant, @@ -1122,7 +1363,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).project; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).project; } /** @@ -1133,7 +1376,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).tenant; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).tenant; } /** @@ -1144,7 +1389,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).company; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).company; } /** @@ -1155,7 +1402,7 @@ export class CompanyServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectTenantJobPath(project:string,tenant:string,job:string) { + projectTenantJobPath(project: string, tenant: string, job: string) { return this.pathTemplates.projectTenantJobPathTemplate.render({ project: project, tenant: tenant, @@ -1171,7 +1418,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).project; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).project; } /** @@ -1182,7 +1431,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).tenant; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).tenant; } /** @@ -1193,7 +1444,9 @@ export class CompanyServiceClient { * @returns {string} A string representing the job. */ matchJobFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).job; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).job; } /** @@ -1203,7 +1456,7 @@ export class CompanyServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -1240,7 +1493,7 @@ export class CompanyServiceClient { */ close(): Promise { if (this.companyServiceStub && !this._terminated) { - return this.companyServiceStub.then(stub => { + return this.companyServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1248,4 +1501,4 @@ export class CompanyServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4beta1/completion_client.ts b/packages/google-cloud-talent/src/v4beta1/completion_client.ts index f58fed9e1a37..5bb3d9b4f6b6 100644 --- a/packages/google-cloud-talent/src/v4beta1/completion_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/completion_client.ts @@ -18,11 +18,16 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; 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 +49,7 @@ export class CompletionClient { 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('talent'); @@ -57,9 +62,9 @@ export class CompletionClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - completionStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + completionStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CompletionClient. @@ -100,21 +105,42 @@ export class CompletionClient { * const client = new CompletionClient({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 CompletionClient; - 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 = 'jobs.' + 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; @@ -139,7 +165,7 @@ export class CompletionClient { 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; @@ -153,10 +179,7 @@ export class CompletionClient { } // 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 { @@ -178,29 +201,32 @@ export class CompletionClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/companies/{company}' + 'projects/{project}/companies/{company}', ), projectJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/jobs/{job}' + 'projects/{project}/jobs/{job}', ), projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4beta1.Completion', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4beta1.Completion', + 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 @@ -231,36 +257,40 @@ export class CompletionClient { // Put together the "service stub" for // google.cloud.talent.v4beta1.Completion. this.completionStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4beta1.Completion') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4beta1.Completion', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4beta1.Completion, - 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 completionStubMethods = - ['completeQuery']; + const completionStubMethods = ['completeQuery']; for (const methodName of completionStubMethods) { const callPromise = this.completionStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -275,8 +305,14 @@ export class CompletionClient { * @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 'jobs.googleapis.com'; } @@ -287,8 +323,14 @@ export class CompletionClient { * @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 'jobs.googleapis.com'; } @@ -321,7 +363,7 @@ export class CompletionClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -331,8 +373,9 @@ export class CompletionClient { * 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; @@ -343,133 +386,173 @@ export class CompletionClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Completes the specified prefix with keyword suggestions. - * Intended for use by a job search auto-complete search box. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of tenant the completion is performed within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". - * - * If tenant id is unspecified, the default tenant is used, for - * example, "projects/foo". - * @param {string} request.query - * Required. The query used to generate suggestions. - * - * The maximum number of allowed characters is 255. - * @param {string[]} request.languageCodes - * The list of languages of the query. This is - * the BCP-47 language code, such as "en-US" or "sr-Latn". - * For more information, see - * [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). - * - * The maximum number of allowed characters is 255. - * @param {number} request.pageSize - * Required. Completion result count. - * - * The maximum allowed page size is 10. - * @param {string} request.company - * If provided, restricts completion to specified company. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for - * example, "projects/foo/tenants/bar/companies/baz". - * - * If tenant id is unspecified, the default tenant is used, for - * example, "projects/foo". - * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope} request.scope - * The scope of the completion. The defaults is - * {@link protos.google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC|CompletionScope.PUBLIC}. - * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType} request.type - * The completion topic. The default is - * {@link protos.google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED|CompletionType.COMBINED}. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.CompleteQueryResponse|CompleteQueryResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/completion.complete_query.js - * region_tag:jobs_v4beta1_generated_Completion_CompleteQuery_async - */ + /** + * Completes the specified prefix with keyword suggestions. + * Intended for use by a job search auto-complete search box. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of tenant the completion is performed within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". + * + * If tenant id is unspecified, the default tenant is used, for + * example, "projects/foo". + * @param {string} request.query + * Required. The query used to generate suggestions. + * + * The maximum number of allowed characters is 255. + * @param {string[]} request.languageCodes + * The list of languages of the query. This is + * the BCP-47 language code, such as "en-US" or "sr-Latn". + * For more information, see + * [Tags for Identifying Languages](https://tools.ietf.org/html/bcp47). + * + * The maximum number of allowed characters is 255. + * @param {number} request.pageSize + * Required. Completion result count. + * + * The maximum allowed page size is 10. + * @param {string} request.company + * If provided, restricts completion to specified company. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}", for + * example, "projects/foo/tenants/bar/companies/baz". + * + * If tenant id is unspecified, the default tenant is used, for + * example, "projects/foo". + * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope} request.scope + * The scope of the completion. The defaults is + * {@link protos.google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionScope.PUBLIC|CompletionScope.PUBLIC}. + * @param {google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType} request.type + * The completion topic. The default is + * {@link protos.google.cloud.talent.v4beta1.CompleteQueryRequest.CompletionType.COMBINED|CompletionType.COMBINED}. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.CompleteQueryResponse|CompleteQueryResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/completion.complete_query.js + * region_tag:jobs_v4beta1_generated_Completion_CompleteQuery_async + */ completeQuery( - request?: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + protos.google.cloud.talent.v4beta1.ICompleteQueryRequest | undefined, + {} | undefined, + ] + >; completeQuery( - request: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + | protos.google.cloud.talent.v4beta1.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; completeQuery( - request: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + | protos.google.cloud.talent.v4beta1.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + ): void; completeQuery( - request?: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.ICompleteQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + | protos.google.cloud.talent.v4beta1.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + protos.google.cloud.talent.v4beta1.ICompleteQueryRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('completeQuery request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + | protos.google.cloud.talent.v4beta1.ICompleteQueryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('completeQuery response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.completeQuery(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, - protos.google.cloud.talent.v4beta1.ICompleteQueryRequest|undefined, - {}|undefined - ]) => { - this._log.info('completeQuery response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .completeQuery(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ICompleteQueryResponse, + protos.google.cloud.talent.v4beta1.ICompleteQueryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('completeQuery response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); @@ -485,7 +568,7 @@ export class CompletionClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -509,7 +592,7 @@ export class CompletionClient { * @param {string} company * @returns {string} Resource name string. */ - projectCompanyPath(project:string,company:string) { + projectCompanyPath(project: string, company: string) { return this.pathTemplates.projectCompanyPathTemplate.render({ project: project, company: company, @@ -524,7 +607,9 @@ export class CompletionClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).project; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).project; } /** @@ -535,7 +620,9 @@ export class CompletionClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).company; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).company; } /** @@ -545,7 +632,7 @@ export class CompletionClient { * @param {string} job * @returns {string} Resource name string. */ - projectJobPath(project:string,job:string) { + projectJobPath(project: string, job: string) { return this.pathTemplates.projectJobPathTemplate.render({ project: project, job: job, @@ -560,7 +647,8 @@ export class CompletionClient { * @returns {string} A string representing the project. */ matchProjectFromProjectJobName(projectJobName: string) { - return this.pathTemplates.projectJobPathTemplate.match(projectJobName).project; + return this.pathTemplates.projectJobPathTemplate.match(projectJobName) + .project; } /** @@ -582,7 +670,7 @@ export class CompletionClient { * @param {string} company * @returns {string} Resource name string. */ - projectTenantCompanyPath(project:string,tenant:string,company:string) { + projectTenantCompanyPath(project: string, tenant: string, company: string) { return this.pathTemplates.projectTenantCompanyPathTemplate.render({ project: project, tenant: tenant, @@ -598,7 +686,9 @@ export class CompletionClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).project; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).project; } /** @@ -609,7 +699,9 @@ export class CompletionClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).tenant; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).tenant; } /** @@ -620,7 +712,9 @@ export class CompletionClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).company; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).company; } /** @@ -631,7 +725,7 @@ export class CompletionClient { * @param {string} job * @returns {string} Resource name string. */ - projectTenantJobPath(project:string,tenant:string,job:string) { + projectTenantJobPath(project: string, tenant: string, job: string) { return this.pathTemplates.projectTenantJobPathTemplate.render({ project: project, tenant: tenant, @@ -647,7 +741,9 @@ export class CompletionClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).project; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).project; } /** @@ -658,7 +754,9 @@ export class CompletionClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).tenant; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).tenant; } /** @@ -669,7 +767,9 @@ export class CompletionClient { * @returns {string} A string representing the job. */ matchJobFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).job; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).job; } /** @@ -679,7 +779,7 @@ export class CompletionClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -716,7 +816,7 @@ export class CompletionClient { */ close(): Promise { if (this.completionStub && !this._terminated) { - return this.completionStub.then(stub => { + return this.completionStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -724,4 +824,4 @@ export class CompletionClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4beta1/event_service_client.ts b/packages/google-cloud-talent/src/v4beta1/event_service_client.ts index 575cffb45f4c..5a0468852041 100644 --- a/packages/google-cloud-talent/src/v4beta1/event_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/event_service_client.ts @@ -18,11 +18,16 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, +} from 'google-gax'; 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 +49,7 @@ export class EventServiceClient { 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('talent'); @@ -57,9 +62,9 @@ export class EventServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - eventServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + eventServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of EventServiceClient. @@ -100,21 +105,42 @@ export class EventServiceClient { * const client = new EventServiceClient({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 EventServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +165,7 @@ export class EventServiceClient { 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; @@ -153,10 +179,7 @@ export class EventServiceClient { } // 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 { @@ -178,29 +201,32 @@ export class EventServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/companies/{company}' + 'projects/{project}/companies/{company}', ), projectJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/jobs/{job}' + 'projects/{project}/jobs/{job}', ), projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4beta1.EventService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4beta1.EventService', + 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 @@ -231,36 +257,40 @@ export class EventServiceClient { // Put together the "service stub" for // google.cloud.talent.v4beta1.EventService. this.eventServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4beta1.EventService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4beta1.EventService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4beta1.EventService, - 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 eventServiceStubMethods = - ['createClientEvent']; + const eventServiceStubMethods = ['createClientEvent']; for (const methodName of eventServiceStubMethods) { const callPromise = this.eventServiceStub.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 = - undefined; + const descriptor = undefined; const apiCall = this._gaxModule.createApiCall( callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -275,8 +305,14 @@ export class EventServiceClient { * @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 'jobs.googleapis.com'; } @@ -287,8 +323,14 @@ export class EventServiceClient { * @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 'jobs.googleapis.com'; } @@ -321,7 +363,7 @@ export class EventServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -331,8 +373,9 @@ export class EventServiceClient { * 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; @@ -343,109 +386,152 @@ export class EventServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Report events issued when end user interacts with customer's application - * that uses Cloud Talent Solution. You may inspect the created events in - * [self service - * tools](https://console.cloud.google.com/talent-solution/overview). - * [Learn - * more](https://cloud.google.com/talent-solution/docs/management-tools) - * about self service tools. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the tenant under which the event is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created, for example, "projects/foo". - * @param {google.cloud.talent.v4beta1.ClientEvent} request.clientEvent - * Required. Events issued when end user interacts with customer's application - * that uses Cloud Talent Solution. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.ClientEvent|ClientEvent}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/event_service.create_client_event.js - * region_tag:jobs_v4beta1_generated_EventService_CreateClientEvent_async - */ + /** + * Report events issued when end user interacts with customer's application + * that uses Cloud Talent Solution. You may inspect the created events in + * [self service + * tools](https://console.cloud.google.com/talent-solution/overview). + * [Learn + * more](https://cloud.google.com/talent-solution/docs/management-tools) + * about self service tools. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the tenant under which the event is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created, for example, "projects/foo". + * @param {google.cloud.talent.v4beta1.ClientEvent} request.clientEvent + * Required. Events issued when end user interacts with customer's application + * that uses Cloud Talent Solution. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.ClientEvent|ClientEvent}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/event_service.create_client_event.js + * region_tag:jobs_v4beta1_generated_EventService_CreateClientEvent_async + */ createClientEvent( - request?: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IClientEvent, + protos.google.cloud.talent.v4beta1.ICreateClientEventRequest | undefined, + {} | undefined, + ] + >; createClientEvent( - request: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.IClientEvent, + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createClientEvent( - request: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.IClientEvent, + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createClientEvent( - request?: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4beta1.ICreateClientEventRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.IClientEvent, + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IClientEvent, + protos.google.cloud.talent.v4beta1.ICreateClientEventRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createClientEvent request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.IClientEvent, + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createClientEvent response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createClientEvent(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.IClientEvent, - protos.google.cloud.talent.v4beta1.ICreateClientEventRequest|undefined, - {}|undefined - ]) => { - this._log.info('createClientEvent response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createClientEvent(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.IClientEvent, + ( + | protos.google.cloud.talent.v4beta1.ICreateClientEventRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('createClientEvent response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); @@ -461,7 +547,7 @@ export class EventServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -485,7 +571,7 @@ export class EventServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectCompanyPath(project:string,company:string) { + projectCompanyPath(project: string, company: string) { return this.pathTemplates.projectCompanyPathTemplate.render({ project: project, company: company, @@ -500,7 +586,9 @@ export class EventServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).project; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).project; } /** @@ -511,7 +599,9 @@ export class EventServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).company; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).company; } /** @@ -521,7 +611,7 @@ export class EventServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectJobPath(project:string,job:string) { + projectJobPath(project: string, job: string) { return this.pathTemplates.projectJobPathTemplate.render({ project: project, job: job, @@ -536,7 +626,8 @@ export class EventServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectJobName(projectJobName: string) { - return this.pathTemplates.projectJobPathTemplate.match(projectJobName).project; + return this.pathTemplates.projectJobPathTemplate.match(projectJobName) + .project; } /** @@ -558,7 +649,7 @@ export class EventServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectTenantCompanyPath(project:string,tenant:string,company:string) { + projectTenantCompanyPath(project: string, tenant: string, company: string) { return this.pathTemplates.projectTenantCompanyPathTemplate.render({ project: project, tenant: tenant, @@ -574,7 +665,9 @@ export class EventServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).project; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).project; } /** @@ -585,7 +678,9 @@ export class EventServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).tenant; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).tenant; } /** @@ -596,7 +691,9 @@ export class EventServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).company; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).company; } /** @@ -607,7 +704,7 @@ export class EventServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectTenantJobPath(project:string,tenant:string,job:string) { + projectTenantJobPath(project: string, tenant: string, job: string) { return this.pathTemplates.projectTenantJobPathTemplate.render({ project: project, tenant: tenant, @@ -623,7 +720,9 @@ export class EventServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).project; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).project; } /** @@ -634,7 +733,9 @@ export class EventServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).tenant; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).tenant; } /** @@ -645,7 +746,9 @@ export class EventServiceClient { * @returns {string} A string representing the job. */ matchJobFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).job; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).job; } /** @@ -655,7 +758,7 @@ export class EventServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -692,7 +795,7 @@ export class EventServiceClient { */ close(): Promise { if (this.eventServiceStub && !this._terminated) { - return this.eventServiceStub.then(stub => { + return this.eventServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -700,4 +803,4 @@ export class EventServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4beta1/index.ts b/packages/google-cloud-talent/src/v4beta1/index.ts index 69bfaedb86e3..8f9887feb507 100644 --- a/packages/google-cloud-talent/src/v4beta1/index.ts +++ b/packages/google-cloud-talent/src/v4beta1/index.ts @@ -16,8 +16,8 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CompanyServiceClient} from './company_service_client'; -export {CompletionClient} from './completion_client'; -export {EventServiceClient} from './event_service_client'; -export {JobServiceClient} from './job_service_client'; -export {TenantServiceClient} from './tenant_service_client'; +export { CompanyServiceClient } from './company_service_client'; +export { CompletionClient } from './completion_client'; +export { EventServiceClient } from './event_service_client'; +export { JobServiceClient } from './job_service_client'; +export { TenantServiceClient } from './tenant_service_client'; diff --git a/packages/google-cloud-talent/src/v4beta1/job_service_client.ts b/packages/google-cloud-talent/src/v4beta1/job_service_client.ts index 6fae86894dc2..04a9d916008d 100644 --- a/packages/google-cloud-talent/src/v4beta1/job_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/job_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 JobServiceClient { 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('talent'); @@ -57,10 +66,10 @@ export class JobServiceClient { 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; - jobServiceStub?: Promise<{[name: string]: Function}>; + jobServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of JobServiceClient. @@ -101,21 +110,42 @@ export class JobServiceClient { * const client = new JobServiceClient({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 JobServiceClient; - 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 = 'jobs.' + 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 JobServiceClient { 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 JobServiceClient { } // 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,22 +206,22 @@ export class JobServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/companies/{company}' + 'projects/{project}/companies/{company}', ), projectJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/jobs/{job}' + 'projects/{project}/jobs/{job}', ), projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -202,8 +229,11 @@ export class JobServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listJobs: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'jobs') + listJobs: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'jobs', + ), }; const protoFilesRoot = this._gaxModule.protobufFromJSON(jsonProtos); @@ -212,37 +242,53 @@ export class JobServiceClient { // 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.longrunning.Operations.GetOperation',get: '/v4beta1/{name=projects/*/operations/*}',}]; + lroOptions.httpRules = [ + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v4beta1/{name=projects/*/operations/*}', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const batchCreateJobsResponse = protoFilesRoot.lookup( - '.google.cloud.talent.v4beta1.JobOperationResult') as gax.protobuf.Type; + '.google.cloud.talent.v4beta1.JobOperationResult', + ) as gax.protobuf.Type; const batchCreateJobsMetadata = protoFilesRoot.lookup( - '.google.cloud.talent.v4beta1.BatchOperationMetadata') as gax.protobuf.Type; + '.google.cloud.talent.v4beta1.BatchOperationMetadata', + ) as gax.protobuf.Type; const batchUpdateJobsResponse = protoFilesRoot.lookup( - '.google.cloud.talent.v4beta1.JobOperationResult') as gax.protobuf.Type; + '.google.cloud.talent.v4beta1.JobOperationResult', + ) as gax.protobuf.Type; const batchUpdateJobsMetadata = protoFilesRoot.lookup( - '.google.cloud.talent.v4beta1.BatchOperationMetadata') as gax.protobuf.Type; + '.google.cloud.talent.v4beta1.BatchOperationMetadata', + ) as gax.protobuf.Type; this.descriptors.longrunning = { batchCreateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchCreateJobsResponse.decode.bind(batchCreateJobsResponse), - batchCreateJobsMetadata.decode.bind(batchCreateJobsMetadata)), + batchCreateJobsMetadata.decode.bind(batchCreateJobsMetadata), + ), batchUpdateJobs: new this._gaxModule.LongrunningDescriptor( this.operationsClient, batchUpdateJobsResponse.decode.bind(batchUpdateJobsResponse), - batchUpdateJobsMetadata.decode.bind(batchUpdateJobsMetadata)) + batchUpdateJobsMetadata.decode.bind(batchUpdateJobsMetadata), + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4beta1.JobService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4beta1.JobService', + 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 @@ -273,28 +319,44 @@ export class JobServiceClient { // Put together the "service stub" for // google.cloud.talent.v4beta1.JobService. this.jobServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4beta1.JobService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4beta1.JobService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4beta1.JobService, - 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 jobServiceStubMethods = - ['createJob', 'batchCreateJobs', 'getJob', 'updateJob', 'batchUpdateJobs', 'deleteJob', 'batchDeleteJobs', 'listJobs', 'searchJobs', 'searchJobsForAlert']; + const jobServiceStubMethods = [ + 'createJob', + 'batchCreateJobs', + 'getJob', + 'updateJob', + 'batchUpdateJobs', + 'deleteJob', + 'batchDeleteJobs', + 'listJobs', + 'searchJobs', + 'searchJobsForAlert', + ]; for (const methodName of jobServiceStubMethods) { const callPromise = this.jobServiceStub.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] || @@ -304,7 +366,7 @@ export class JobServiceClient { callPromise, this._defaults[methodName], descriptor, - this._opts.fallback + this._opts.fallback, ); this.innerApiCalls[methodName] = apiCall; @@ -319,8 +381,14 @@ export class JobServiceClient { * @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 'jobs.googleapis.com'; } @@ -331,8 +399,14 @@ export class JobServiceClient { * @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 'jobs.googleapis.com'; } @@ -365,7 +439,7 @@ export class JobServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -375,8 +449,9 @@ export class JobServiceClient { * 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; @@ -387,1670 +462,2056 @@ export class JobServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new job. - * - * Typically, the job becomes searchable within 10 seconds, but it may take - * up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified a default tenant - * is created. For example, "projects/foo". - * @param {google.cloud.talent.v4beta1.Job} request.job - * Required. The Job 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 {@link protos.google.cloud.talent.v4beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.create_job.js - * region_tag:jobs_v4beta1_generated_JobService_CreateJob_async - */ + /** + * Creates a new job. + * + * Typically, the job becomes searchable within 10 seconds, but it may take + * up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified a default tenant + * is created. For example, "projects/foo". + * @param {google.cloud.talent.v4beta1.Job} request.job + * Required. The Job 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 {@link protos.google.cloud.talent.v4beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.create_job.js + * region_tag:jobs_v4beta1_generated_JobService_CreateJob_async + */ createJob( - request?: protos.google.cloud.talent.v4beta1.ICreateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ICreateJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | undefined, + {} | undefined, + ] + >; createJob( - request: protos.google.cloud.talent.v4beta1.ICreateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request: protos.google.cloud.talent.v4beta1.ICreateJobRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateJobRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; createJob( - request?: protos.google.cloud.talent.v4beta1.ICreateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.ICreateJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ICreateJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.IJob, + | protos.google.cloud.talent.v4beta1.ICreateJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.ICreateJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('createJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.ICreateJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves the specified job, whose status is OPEN or recently EXPIRED - * within the last 90 days. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the job to retrieve. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For - * example, "projects/foo/tenants/bar/jobs/baz". - * - * If tenant id is unspecified, the default tenant is used. For - * example, "projects/foo/jobs/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.get_job.js - * region_tag:jobs_v4beta1_generated_JobService_GetJob_async - */ + /** + * Retrieves the specified job, whose status is OPEN or recently EXPIRED + * within the last 90 days. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the job to retrieve. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For + * example, "projects/foo/tenants/bar/jobs/baz". + * + * If tenant id is unspecified, the default tenant is used. For + * example, "projects/foo/jobs/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.get_job.js + * region_tag:jobs_v4beta1_generated_JobService_GetJob_async + */ getJob( - request?: protos.google.cloud.talent.v4beta1.IGetJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IGetJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | undefined, + {} | undefined, + ] + >; getJob( - request: protos.google.cloud.talent.v4beta1.IGetJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getJob( - request: protos.google.cloud.talent.v4beta1.IGetJobRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetJobRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): void; getJob( - request?: protos.google.cloud.talent.v4beta1.IGetJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IGetJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.talent.v4beta1.IGetJobRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IGetJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('getJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IGetJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified job. - * - * Typically, updated contents become visible in search results within 10 - * seconds, but it may take up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4beta1.Job} request.job - * Required. The Job to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If {@link protos.google.cloud.talent.v4beta1.UpdateJobRequest.update_mask|update_mask} - * is provided, only the specified fields in - * {@link protos.google.cloud.talent.v4beta1.UpdateJobRequest.job|job} are updated. - * Otherwise all the fields are updated. - * - * A field mask to restrict the fields that are updated. Only - * top level fields of {@link protos.google.cloud.talent.v4beta1.Job|Job} are 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 {@link protos.google.cloud.talent.v4beta1.Job|Job}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.update_job.js - * region_tag:jobs_v4beta1_generated_JobService_UpdateJob_async - */ + /** + * Updates specified job. + * + * Typically, updated contents become visible in search results within 10 + * seconds, but it may take up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4beta1.Job} request.job + * Required. The Job to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If {@link protos.google.cloud.talent.v4beta1.UpdateJobRequest.update_mask|update_mask} + * is provided, only the specified fields in + * {@link protos.google.cloud.talent.v4beta1.UpdateJobRequest.job|job} are updated. + * Otherwise all the fields are updated. + * + * A field mask to restrict the fields that are updated. Only + * top level fields of {@link protos.google.cloud.talent.v4beta1.Job|Job} are 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 {@link protos.google.cloud.talent.v4beta1.Job|Job}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.update_job.js + * region_tag:jobs_v4beta1_generated_JobService_UpdateJob_async + */ updateJob( - request?: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | undefined, + {} | undefined, + ] + >; updateJob( - request: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; updateJob( - request: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): void; updateJob( - request?: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IUpdateJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IUpdateJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'job.name': request.job!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'job.name': request.job!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateJob request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.IJob, + | protos.google.cloud.talent.v4beta1.IUpdateJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.IJob, - protos.google.cloud.talent.v4beta1.IUpdateJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.IJob, + protos.google.cloud.talent.v4beta1.IUpdateJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 the specified job. - * - * Typically, the job becomes unsearchable within 10 seconds, but it may take - * up to 5 minutes. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the job to be deleted. - * - * The format is - * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For - * example, "projects/foo/tenants/bar/jobs/baz". - * - * If tenant id is unspecified, the default tenant is used. For - * example, "projects/foo/jobs/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/job_service.delete_job.js - * region_tag:jobs_v4beta1_generated_JobService_DeleteJob_async - */ + /** + * Deletes the specified job. + * + * Typically, the job becomes unsearchable within 10 seconds, but it may take + * up to 5 minutes. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the job to be deleted. + * + * The format is + * "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For + * example, "projects/foo/tenants/bar/jobs/baz". + * + * If tenant id is unspecified, the default tenant is used. For + * example, "projects/foo/jobs/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/job_service.delete_job.js + * region_tag:jobs_v4beta1_generated_JobService_DeleteJob_async + */ deleteJob( - request?: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | undefined, + {} | undefined, + ] + >; deleteJob( - request: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteJob( - request?: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IDeleteJobRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteJob request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteJobRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteJob response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteJob(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteJobRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteJob response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteJob(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteJobRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteJob response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 list of {@link protos.google.cloud.talent.v4beta1.Job|Job}s by filter. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be deleted. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` (Required) - * * `requisitionId` (Required) - * - * Sample Query: companyName = "projects/foo/companies/bar" AND - * requisitionId = "req-1" - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/job_service.batch_delete_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_BatchDeleteJobs_async - */ + /** + * Deletes a list of {@link protos.google.cloud.talent.v4beta1.Job|Job}s by filter. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be deleted. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` (Required) + * * `requisitionId` (Required) + * + * Sample Query: companyName = "projects/foo/companies/bar" AND + * requisitionId = "req-1" + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/job_service.batch_delete_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_BatchDeleteJobs_async + */ batchDeleteJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest | undefined, + {} | undefined, + ] + >; batchDeleteJobs( - request: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchDeleteJobs( - request: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | null + | undefined, + {} | null | undefined + >, + ): void; batchDeleteJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('batchDeleteJobs request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('batchDeleteJobs response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.batchDeleteJobs(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest|undefined, - {}|undefined - ]) => { - this._log.info('batchDeleteJobs response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .batchDeleteJobs(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + ( + | protos.google.cloud.talent.v4beta1.IBatchDeleteJobsRequest + | undefined + ), + {} | undefined, + ]) => { + this._log.info('batchDeleteJobs response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Searches for jobs using the provided - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. - * - * This call constrains the - * {@link protos.google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs present in - * the database, and only returns jobs that the caller has permission to - * search against. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant to search within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode - * Mode of a search. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. - * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata - * Required. The meta information collected about the job searcher, used to - * improve the search quality of the service. The identifiers (such as - * `user_id`) are provided by users, and must be unique and consistent. - * @param {google.cloud.talent.v4beta1.JobQuery} request.jobQuery - * Query used to search against jobs, such as keyword, location filters, etc. - * @param {boolean} request.enableBroadening - * Controls whether to broaden the search when it produces sparse results. - * Broadened queries append results to the end of the matching results - * list. - * - * Defaults to false. - * @param {boolean} request.requirePreciseResultSize - * This field is deprecated. - * @param {number[]} request.histogramQueries - * An expression specifies a histogram request against matching jobs. - * - * Expression syntax is an aggregation function call with histogram facets and - * other options. - * - * Available aggregation function calls are: - * * `count(string_histogram_facet)`: Count the number of matching entities, - * for each distinct attribute value. - * * `count(numeric_histogram_facet, list of buckets)`: Count the number of - * matching entities within each bucket. - * - * A maximum of 200 histogram buckets are supported. - * - * Data types: - * - * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. - * * String: string like "any string with backslash escape for quote(\")." - * * Number: whole number and floating point number like 10, -1 and -0.01. - * * List: list of elements with comma(,) separator surrounded by square - * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. - * - * Built-in constants: - * - * * MIN (minimum number similar to java Double.MIN_VALUE) - * * MAX (maximum number similar to java Double.MAX_VALUE) - * - * Built-in functions: - * - * * bucket(start, end[, label]): bucket built-in function creates a bucket - * with range of [start, end). Note that the end is exclusive, for example, - * bucket(1, MAX, "positive number") or bucket(1, 10). - * - * Job histogram facets: - * - * * company_display_name: histogram by - * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. - * * employment_type: histogram by - * {@link protos.google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, - * for example, - * "FULL_TIME", "PART_TIME". - * * company_size (DEPRECATED): histogram by - * {@link protos.google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, - * "SMALL", "MEDIUM", "BIG". - * * publish_time_in_day: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in days. - * Must specify list of numeric buckets in spec. - * * publish_time_in_month: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in months. - * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in years. - * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for - * example, - * "Bachelors", "Masters". - * * job_level: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, - * "Entry - * Level". - * * country: histogram by the country code of jobs, for example, "US", "FR". - * * admin1: histogram by the admin1 code of jobs, which is a global - * placeholder referring to the state, province, or the particular term a - * country uses to define the geographic structure below the country level, - * for example, "CA", "IL". - * * city: histogram by a combination of the "city name, admin1 code". For - * example, "Mountain View, CA", "New York, NY". - * * admin1_country: histogram by a combination of the "admin1 code, country", - * for example, "CA, US", "IL, US". - * * city_coordinate: histogram by the city center's GPS coordinates (latitude - * and longitude), for example, 37.4038522,-122.0987765. Since the - * coordinates of a city center can change, customers may need to refresh - * them periodically. - * * locale: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for - * example, "en-US", - * "fr-FR". - * * language: histogram by the language subtag of the - * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, - * for example, "en", "fr". - * * category: histogram by the - * {@link protos.google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, - * "COMPUTER_AND_IT", "HEALTHCARE". - * * base_compensation_unit: histogram by the - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} - * of base salary, for example, "WEEKLY", "MONTHLY". - * * base_compensation: histogram by the base salary. Must specify list of - * numeric buckets to group results by. - * * annualized_base_compensation: histogram by the base annualized salary. - * Must specify list of numeric buckets to group results by. - * * annualized_total_compensation: histogram by the total annualized salary. - * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string - * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric - * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to - * group results by. - * - * Example expressions: - * - * * `count(admin1)` - * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), - * bucket(100000, MAX)])` - * * `count(string_custom_attribute["some-string-custom-attribute"])` - * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], - * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` - * @param {google.cloud.talent.v4beta1.JobView} request.jobView - * The desired job attributes returned for jobs in the search response. - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} - * if no value is specified. - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is - * unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * job, and 10 means to return from the 11th job. This can be used for - * pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.pageSize - * A limit on the number of jobs returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within - * search results. See - * {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} - * for an explanation of how to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. Default is - * `"relevance desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. Relevance thresholding of query results is only available - * with this ordering. - * * `"posting_publish_time desc"`: By - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * descending. - * * `"posting_update_time desc"`: By - * {@link protos.google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} - * descending. - * * `"title"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} - * ascending. - * * `"title desc"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} - * descending. - * * `"annualized_base_compensation"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_base_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"annualized_total_compensation"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_total_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"custom_ranking desc"`: By the relevance score adjusted to the - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} - * with weight factor assigned by - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} - * in descending order. - * * Location sorting: Use the special syntax to order jobs by distance:
- * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
- * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
- * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by - * multiple locations. See details below.
- * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by - * multiple locations. See details below.
- * The string can have a maximum of 256 characters. When multiple distance - * centers are provided, a job that is close to any of the distance centers - * would have a high rank. When a job has multiple locations, the job - * location closest to one of the distance centers will be used. Jobs that - * don't have locations will be ranked at the bottom. Distance is calculated - * with a precision of 11.3 meters (37.4 feet). Diversification strategy is - * still applied unless explicitly disabled in - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel - * Controls whether highly similar jobs are returned next to each other in - * the search results. Jobs are identified as highly similar based on - * their titles, job categories, and locations. Highly similar results are - * clustered so that only one representative job of the cluster is - * displayed to the job seeker higher up in the results, with the other jobs - * being displayed lower down in the results. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} - * if no value is specified. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo - * Controls over how job documents get ranked on top of existing relevance - * score (determined by API algorithm). - * @param {boolean} request.disableKeywordMatch - * This field is deprecated. Please use - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * going forward. - * - * To migrate, disable_keyword_match set to false maps to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, - * and disable_keyword_match set to true maps to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. - * If - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * is set, this field is ignored. - * - * Controls whether to disable exact keyword match on - * {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title}, - * {@link protos.google.cloud.talent.v4beta1.Job.description|Job.description}, - * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, - * {@link protos.google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, - * {@link protos.google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When - * disable keyword match is turned off, a keyword match returns jobs that do - * not match given category filters when there are matching keywords. For - * example, for the query "program manager," a result is returned even if the - * job posting has the title "software developer," which doesn't fall into - * "program manager" ontology, but does have "program manager" appearing in - * its description. - * - * For queries like "cloud" that don't contain title or - * location specific ontology, jobs with "cloud" keyword matches are returned - * regardless of this flag's value. - * - * Use - * {@link protos.google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} - * if company-specific globally matched custom field/attribute string values - * are needed. Enabling keyword match improves recall of subsequent search - * requests. - * - * Defaults to false. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode - * Controls what keyword match options to use. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} - * if no value is specified. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] - * Optional. The relevance threshold of the search results. - * - * Default to Google defined threshold, leveraging a balance of - * precision and recall to deliver both highly accurate results and - * comprehensive coverage of relevant information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse|SearchJobsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.search_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_SearchJobs_async - */ + /** + * Searches for jobs using the provided + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. + * + * This call constrains the + * {@link protos.google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs present in + * the database, and only returns jobs that the caller has permission to + * search against. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant to search within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode + * Mode of a search. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. + * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata + * Required. The meta information collected about the job searcher, used to + * improve the search quality of the service. The identifiers (such as + * `user_id`) are provided by users, and must be unique and consistent. + * @param {google.cloud.talent.v4beta1.JobQuery} request.jobQuery + * Query used to search against jobs, such as keyword, location filters, etc. + * @param {boolean} request.enableBroadening + * Controls whether to broaden the search when it produces sparse results. + * Broadened queries append results to the end of the matching results + * list. + * + * Defaults to false. + * @param {boolean} request.requirePreciseResultSize + * This field is deprecated. + * @param {number[]} request.histogramQueries + * An expression specifies a histogram request against matching jobs. + * + * Expression syntax is an aggregation function call with histogram facets and + * other options. + * + * Available aggregation function calls are: + * * `count(string_histogram_facet)`: Count the number of matching entities, + * for each distinct attribute value. + * * `count(numeric_histogram_facet, list of buckets)`: Count the number of + * matching entities within each bucket. + * + * A maximum of 200 histogram buckets are supported. + * + * Data types: + * + * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. + * * String: string like "any string with backslash escape for quote(\")." + * * Number: whole number and floating point number like 10, -1 and -0.01. + * * List: list of elements with comma(,) separator surrounded by square + * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. + * + * Built-in constants: + * + * * MIN (minimum number similar to java Double.MIN_VALUE) + * * MAX (maximum number similar to java Double.MAX_VALUE) + * + * Built-in functions: + * + * * bucket(start, end[, label]): bucket built-in function creates a bucket + * with range of [start, end). Note that the end is exclusive, for example, + * bucket(1, MAX, "positive number") or bucket(1, 10). + * + * Job histogram facets: + * + * * company_display_name: histogram by + * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by + * {@link protos.google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, + * for example, + * "FULL_TIME", "PART_TIME". + * * company_size (DEPRECATED): histogram by + * {@link protos.google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, + * "SMALL", "MEDIUM", "BIG". + * * publish_time_in_day: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in days. + * Must specify list of numeric buckets in spec. + * * publish_time_in_month: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in months. + * Must specify list of numeric buckets in spec. + * * publish_time_in_year: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in years. + * Must specify list of numeric buckets in spec. + * * degree_types: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for + * example, + * "Bachelors", "Masters". + * * job_level: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, + * "Entry + * Level". + * * country: histogram by the country code of jobs, for example, "US", "FR". + * * admin1: histogram by the admin1 code of jobs, which is a global + * placeholder referring to the state, province, or the particular term a + * country uses to define the geographic structure below the country level, + * for example, "CA", "IL". + * * city: histogram by a combination of the "city name, admin1 code". For + * example, "Mountain View, CA", "New York, NY". + * * admin1_country: histogram by a combination of the "admin1 code, country", + * for example, "CA, US", "IL, US". + * * city_coordinate: histogram by the city center's GPS coordinates (latitude + * and longitude), for example, 37.4038522,-122.0987765. Since the + * coordinates of a city center can change, customers may need to refresh + * them periodically. + * * locale: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for + * example, "en-US", + * "fr-FR". + * * language: histogram by the language subtag of the + * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, + * for example, "en", "fr". + * * category: histogram by the + * {@link protos.google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, + * "COMPUTER_AND_IT", "HEALTHCARE". + * * base_compensation_unit: histogram by the + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} + * of base salary, for example, "WEEKLY", "MONTHLY". + * * base_compensation: histogram by the base salary. Must specify list of + * numeric buckets to group results by. + * * annualized_base_compensation: histogram by the base annualized salary. + * Must specify list of numeric buckets to group results by. + * * annualized_total_compensation: histogram by the total annualized salary. + * Must specify list of numeric buckets to group results by. + * * string_custom_attribute: histogram by string + * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * string_custom_attribute["key1"]. + * * numeric_custom_attribute: histogram by numeric + * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to + * group results by. + * + * Example expressions: + * + * * `count(admin1)` + * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), + * bucket(100000, MAX)])` + * * `count(string_custom_attribute["some-string-custom-attribute"])` + * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], + * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` + * @param {google.cloud.talent.v4beta1.JobView} request.jobView + * The desired job attributes returned for jobs in the search response. + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} + * if no value is specified. + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the jobs deemed by the API as relevant) in search + * results. This field is only considered if + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is + * unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * job, and 10 means to return from the 11th job. This can be used for + * pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.pageSize + * A limit on the number of jobs returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within + * search results. See + * {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} + * for an explanation of how to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. Default is + * `"relevance desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. Relevance thresholding of query results is only available + * with this ordering. + * * `"posting_publish_time desc"`: By + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * descending. + * * `"posting_update_time desc"`: By + * {@link protos.google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} + * descending. + * * `"title"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} + * ascending. + * * `"title desc"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} + * descending. + * * `"annualized_base_compensation"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_base_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"annualized_total_compensation"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_total_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"custom_ranking desc"`: By the relevance score adjusted to the + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} + * with weight factor assigned by + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} + * in descending order. + * * Location sorting: Use the special syntax to order jobs by distance:
+ * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
+ * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
+ * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by + * multiple locations. See details below.
+ * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by + * multiple locations. See details below.
+ * The string can have a maximum of 256 characters. When multiple distance + * centers are provided, a job that is close to any of the distance centers + * would have a high rank. When a job has multiple locations, the job + * location closest to one of the distance centers will be used. Jobs that + * don't have locations will be ranked at the bottom. Distance is calculated + * with a precision of 11.3 meters (37.4 feet). Diversification strategy is + * still applied unless explicitly disabled in + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel + * Controls whether highly similar jobs are returned next to each other in + * the search results. Jobs are identified as highly similar based on + * their titles, job categories, and locations. Highly similar results are + * clustered so that only one representative job of the cluster is + * displayed to the job seeker higher up in the results, with the other jobs + * being displayed lower down in the results. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} + * if no value is specified. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo + * Controls over how job documents get ranked on top of existing relevance + * score (determined by API algorithm). + * @param {boolean} request.disableKeywordMatch + * This field is deprecated. Please use + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * going forward. + * + * To migrate, disable_keyword_match set to false maps to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, + * and disable_keyword_match set to true maps to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. + * If + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * is set, this field is ignored. + * + * Controls whether to disable exact keyword match on + * {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title}, + * {@link protos.google.cloud.talent.v4beta1.Job.description|Job.description}, + * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, + * {@link protos.google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, + * {@link protos.google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When + * disable keyword match is turned off, a keyword match returns jobs that do + * not match given category filters when there are matching keywords. For + * example, for the query "program manager," a result is returned even if the + * job posting has the title "software developer," which doesn't fall into + * "program manager" ontology, but does have "program manager" appearing in + * its description. + * + * For queries like "cloud" that don't contain title or + * location specific ontology, jobs with "cloud" keyword matches are returned + * regardless of this flag's value. + * + * Use + * {@link protos.google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} + * if company-specific globally matched custom field/attribute string values + * are needed. Enabling keyword match improves recall of subsequent search + * requests. + * + * Defaults to false. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode + * Controls what keyword match options to use. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} + * if no value is specified. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] + * Optional. The relevance threshold of the search results. + * + * Default to Google defined threshold, leveraging a balance of + * precision and recall to deliver both highly accurate results and + * comprehensive coverage of relevant information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse|SearchJobsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.search_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_SearchJobs_async + */ searchJobs( - request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ] + >; searchJobs( - request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobs( - request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobs( - request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ISearchJobsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('searchJobs request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + | protos.google.cloud.talent.v4beta1.ISearchJobsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('searchJobs response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.searchJobs(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, - {}|undefined - ]) => { - this._log.info('searchJobs response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .searchJobs(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('searchJobs response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Searches for jobs using the provided - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. - * - * This API call is intended for the use case of targeting passive job - * seekers (for example, job seekers who have signed up to receive email - * alerts about potential job opportunities), and has different algorithmic - * adjustments that are targeted to passive job seekers. - * - * This call constrains the - * {@link protos.google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs present in - * the database, and only returns jobs the caller has permission to search - * against. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant to search within. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode - * Mode of a search. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. - * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata - * Required. The meta information collected about the job searcher, used to - * improve the search quality of the service. The identifiers (such as - * `user_id`) are provided by users, and must be unique and consistent. - * @param {google.cloud.talent.v4beta1.JobQuery} request.jobQuery - * Query used to search against jobs, such as keyword, location filters, etc. - * @param {boolean} request.enableBroadening - * Controls whether to broaden the search when it produces sparse results. - * Broadened queries append results to the end of the matching results - * list. - * - * Defaults to false. - * @param {boolean} request.requirePreciseResultSize - * This field is deprecated. - * @param {number[]} request.histogramQueries - * An expression specifies a histogram request against matching jobs. - * - * Expression syntax is an aggregation function call with histogram facets and - * other options. - * - * Available aggregation function calls are: - * * `count(string_histogram_facet)`: Count the number of matching entities, - * for each distinct attribute value. - * * `count(numeric_histogram_facet, list of buckets)`: Count the number of - * matching entities within each bucket. - * - * A maximum of 200 histogram buckets are supported. - * - * Data types: - * - * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. - * * String: string like "any string with backslash escape for quote(\")." - * * Number: whole number and floating point number like 10, -1 and -0.01. - * * List: list of elements with comma(,) separator surrounded by square - * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. - * - * Built-in constants: - * - * * MIN (minimum number similar to java Double.MIN_VALUE) - * * MAX (maximum number similar to java Double.MAX_VALUE) - * - * Built-in functions: - * - * * bucket(start, end[, label]): bucket built-in function creates a bucket - * with range of [start, end). Note that the end is exclusive, for example, - * bucket(1, MAX, "positive number") or bucket(1, 10). - * - * Job histogram facets: - * - * * company_display_name: histogram by - * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. - * * employment_type: histogram by - * {@link protos.google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, - * for example, - * "FULL_TIME", "PART_TIME". - * * company_size (DEPRECATED): histogram by - * {@link protos.google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, - * "SMALL", "MEDIUM", "BIG". - * * publish_time_in_day: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in days. - * Must specify list of numeric buckets in spec. - * * publish_time_in_month: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in months. - * Must specify list of numeric buckets in spec. - * * publish_time_in_year: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * in years. - * Must specify list of numeric buckets in spec. - * * degree_types: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for - * example, - * "Bachelors", "Masters". - * * job_level: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, - * "Entry - * Level". - * * country: histogram by the country code of jobs, for example, "US", "FR". - * * admin1: histogram by the admin1 code of jobs, which is a global - * placeholder referring to the state, province, or the particular term a - * country uses to define the geographic structure below the country level, - * for example, "CA", "IL". - * * city: histogram by a combination of the "city name, admin1 code". For - * example, "Mountain View, CA", "New York, NY". - * * admin1_country: histogram by a combination of the "admin1 code, country", - * for example, "CA, US", "IL, US". - * * city_coordinate: histogram by the city center's GPS coordinates (latitude - * and longitude), for example, 37.4038522,-122.0987765. Since the - * coordinates of a city center can change, customers may need to refresh - * them periodically. - * * locale: histogram by the - * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for - * example, "en-US", - * "fr-FR". - * * language: histogram by the language subtag of the - * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, - * for example, "en", "fr". - * * category: histogram by the - * {@link protos.google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, - * "COMPUTER_AND_IT", "HEALTHCARE". - * * base_compensation_unit: histogram by the - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} - * of base salary, for example, "WEEKLY", "MONTHLY". - * * base_compensation: histogram by the base salary. Must specify list of - * numeric buckets to group results by. - * * annualized_base_compensation: histogram by the base annualized salary. - * Must specify list of numeric buckets to group results by. - * * annualized_total_compensation: histogram by the total annualized salary. - * Must specify list of numeric buckets to group results by. - * * string_custom_attribute: histogram by string - * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * string_custom_attribute["key1"]. - * * numeric_custom_attribute: histogram by numeric - * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. - * Values can be accessed via square bracket notations like - * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to - * group results by. - * - * Example expressions: - * - * * `count(admin1)` - * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), - * bucket(100000, MAX)])` - * * `count(string_custom_attribute["some-string-custom-attribute"])` - * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], - * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` - * @param {google.cloud.talent.v4beta1.JobView} request.jobView - * The desired job attributes returned for jobs in the search response. - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} - * if no value is specified. - * @param {number} request.offset - * An integer that specifies the current offset (that is, starting result - * location, amongst the jobs deemed by the API as relevant) in search - * results. This field is only considered if - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is - * unset. - * - * The maximum allowed value is 5000. Otherwise an error is thrown. - * - * For example, 0 means to return results starting from the first matching - * job, and 10 means to return from the 11th job. This can be used for - * pagination, (for example, pageSize = 10 and offset = 10 means to return - * from the second page). - * @param {number} request.pageSize - * A limit on the number of jobs returned in the search results. - * Increasing this value above the default value of 10 can increase search - * response time. The value can be between 1 and 100. - * @param {string} request.pageToken - * The token specifying the current offset within - * search results. See - * {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} - * for an explanation of how to obtain the next set of query results. - * @param {string} request.orderBy - * The criteria determining how search results are sorted. Default is - * `"relevance desc"`. - * - * Supported options are: - * - * * `"relevance desc"`: By relevance descending, as determined by the API - * algorithms. Relevance thresholding of query results is only available - * with this ordering. - * * `"posting_publish_time desc"`: By - * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} - * descending. - * * `"posting_update_time desc"`: By - * {@link protos.google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} - * descending. - * * `"title"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} - * ascending. - * * `"title desc"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} - * descending. - * * `"annualized_base_compensation"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_base_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"annualized_total_compensation"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * ascending. Jobs whose annualized base compensation is unspecified are put - * at the end of search results. - * * `"annualized_total_compensation desc"`: By job's - * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} - * descending. Jobs whose annualized base compensation is unspecified are - * put at the end of search results. - * * `"custom_ranking desc"`: By the relevance score adjusted to the - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} - * with weight factor assigned by - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} - * in descending order. - * * Location sorting: Use the special syntax to order jobs by distance:
- * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
- * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
- * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by - * multiple locations. See details below.
- * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by - * multiple locations. See details below.
- * The string can have a maximum of 256 characters. When multiple distance - * centers are provided, a job that is close to any of the distance centers - * would have a high rank. When a job has multiple locations, the job - * location closest to one of the distance centers will be used. Jobs that - * don't have locations will be ranked at the bottom. Distance is calculated - * with a precision of 11.3 meters (37.4 feet). Diversification strategy is - * still applied unless explicitly disabled in - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel - * Controls whether highly similar jobs are returned next to each other in - * the search results. Jobs are identified as highly similar based on - * their titles, job categories, and locations. Highly similar results are - * clustered so that only one representative job of the cluster is - * displayed to the job seeker higher up in the results, with the other jobs - * being displayed lower down in the results. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} - * if no value is specified. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo - * Controls over how job documents get ranked on top of existing relevance - * score (determined by API algorithm). - * @param {boolean} request.disableKeywordMatch - * This field is deprecated. Please use - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * going forward. - * - * To migrate, disable_keyword_match set to false maps to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, - * and disable_keyword_match set to true maps to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. - * If - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} - * is set, this field is ignored. - * - * Controls whether to disable exact keyword match on - * {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title}, - * {@link protos.google.cloud.talent.v4beta1.Job.description|Job.description}, - * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, - * {@link protos.google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, - * {@link protos.google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When - * disable keyword match is turned off, a keyword match returns jobs that do - * not match given category filters when there are matching keywords. For - * example, for the query "program manager," a result is returned even if the - * job posting has the title "software developer," which doesn't fall into - * "program manager" ontology, but does have "program manager" appearing in - * its description. - * - * For queries like "cloud" that don't contain title or - * location specific ontology, jobs with "cloud" keyword matches are returned - * regardless of this flag's value. - * - * Use - * {@link protos.google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} - * if company-specific globally matched custom field/attribute string values - * are needed. Enabling keyword match improves recall of subsequent search - * requests. - * - * Defaults to false. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode - * Controls what keyword match options to use. - * - * Defaults to - * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} - * if no value is specified. - * @param {google.cloud.talent.v4beta1.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] - * Optional. The relevance threshold of the search results. - * - * Default to Google defined threshold, leveraging a balance of - * precision and recall to deliver both highly accurate results and - * comprehensive coverage of relevant information. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse|SearchJobsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.search_jobs_for_alert.js - * region_tag:jobs_v4beta1_generated_JobService_SearchJobsForAlert_async - */ + /** + * Searches for jobs using the provided + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest|SearchJobsRequest}. + * + * This API call is intended for the use case of targeting passive job + * seekers (for example, job seekers who have signed up to receive email + * alerts about potential job opportunities), and has different algorithmic + * adjustments that are targeted to passive job seekers. + * + * This call constrains the + * {@link protos.google.cloud.talent.v4beta1.Job.visibility|visibility} of jobs present in + * the database, and only returns jobs the caller has permission to search + * against. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant to search within. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode} request.searchMode + * Mode of a search. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.SearchMode.JOB_SEARCH|SearchMode.JOB_SEARCH}. + * @param {google.cloud.talent.v4beta1.RequestMetadata} request.requestMetadata + * Required. The meta information collected about the job searcher, used to + * improve the search quality of the service. The identifiers (such as + * `user_id`) are provided by users, and must be unique and consistent. + * @param {google.cloud.talent.v4beta1.JobQuery} request.jobQuery + * Query used to search against jobs, such as keyword, location filters, etc. + * @param {boolean} request.enableBroadening + * Controls whether to broaden the search when it produces sparse results. + * Broadened queries append results to the end of the matching results + * list. + * + * Defaults to false. + * @param {boolean} request.requirePreciseResultSize + * This field is deprecated. + * @param {number[]} request.histogramQueries + * An expression specifies a histogram request against matching jobs. + * + * Expression syntax is an aggregation function call with histogram facets and + * other options. + * + * Available aggregation function calls are: + * * `count(string_histogram_facet)`: Count the number of matching entities, + * for each distinct attribute value. + * * `count(numeric_histogram_facet, list of buckets)`: Count the number of + * matching entities within each bucket. + * + * A maximum of 200 histogram buckets are supported. + * + * Data types: + * + * * Histogram facet: facet names with format `{@link protos.a-zA-Z0-9_|a-zA-Z}+`. + * * String: string like "any string with backslash escape for quote(\")." + * * Number: whole number and floating point number like 10, -1 and -0.01. + * * List: list of elements with comma(,) separator surrounded by square + * brackets, for example, [1, 2, 3] and ["one", "two", "three"]. + * + * Built-in constants: + * + * * MIN (minimum number similar to java Double.MIN_VALUE) + * * MAX (maximum number similar to java Double.MAX_VALUE) + * + * Built-in functions: + * + * * bucket(start, end[, label]): bucket built-in function creates a bucket + * with range of [start, end). Note that the end is exclusive, for example, + * bucket(1, MAX, "positive number") or bucket(1, 10). + * + * Job histogram facets: + * + * * company_display_name: histogram by + * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}. + * * employment_type: histogram by + * {@link protos.google.cloud.talent.v4beta1.Job.employment_types|Job.employment_types}, + * for example, + * "FULL_TIME", "PART_TIME". + * * company_size (DEPRECATED): histogram by + * {@link protos.google.cloud.talent.v4beta1.CompanySize|CompanySize}, for example, + * "SMALL", "MEDIUM", "BIG". + * * publish_time_in_day: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in days. + * Must specify list of numeric buckets in spec. + * * publish_time_in_month: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in months. + * Must specify list of numeric buckets in spec. + * * publish_time_in_year: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * in years. + * Must specify list of numeric buckets in spec. + * * degree_types: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.degree_types|Job.degree_types}, for + * example, + * "Bachelors", "Masters". + * * job_level: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.job_level|Job.job_level}, for example, + * "Entry + * Level". + * * country: histogram by the country code of jobs, for example, "US", "FR". + * * admin1: histogram by the admin1 code of jobs, which is a global + * placeholder referring to the state, province, or the particular term a + * country uses to define the geographic structure below the country level, + * for example, "CA", "IL". + * * city: histogram by a combination of the "city name, admin1 code". For + * example, "Mountain View, CA", "New York, NY". + * * admin1_country: histogram by a combination of the "admin1 code, country", + * for example, "CA, US", "IL, US". + * * city_coordinate: histogram by the city center's GPS coordinates (latitude + * and longitude), for example, 37.4038522,-122.0987765. Since the + * coordinates of a city center can change, customers may need to refresh + * them periodically. + * * locale: histogram by the + * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, for + * example, "en-US", + * "fr-FR". + * * language: histogram by the language subtag of the + * {@link protos.google.cloud.talent.v4beta1.Job.language_code|Job.language_code}, + * for example, "en", "fr". + * * category: histogram by the + * {@link protos.google.cloud.talent.v4beta1.JobCategory|JobCategory}, for example, + * "COMPUTER_AND_IT", "HEALTHCARE". + * * base_compensation_unit: histogram by the + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.CompensationUnit|CompensationInfo.CompensationUnit} + * of base salary, for example, "WEEKLY", "MONTHLY". + * * base_compensation: histogram by the base salary. Must specify list of + * numeric buckets to group results by. + * * annualized_base_compensation: histogram by the base annualized salary. + * Must specify list of numeric buckets to group results by. + * * annualized_total_compensation: histogram by the total annualized salary. + * Must specify list of numeric buckets to group results by. + * * string_custom_attribute: histogram by string + * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * string_custom_attribute["key1"]. + * * numeric_custom_attribute: histogram by numeric + * {@link protos.google.cloud.talent.v4beta1.Job.custom_attributes|Job.custom_attributes}. + * Values can be accessed via square bracket notations like + * numeric_custom_attribute["key1"]. Must specify list of numeric buckets to + * group results by. + * + * Example expressions: + * + * * `count(admin1)` + * * `count(base_compensation, [bucket(1000, 10000), bucket(10000, 100000), + * bucket(100000, MAX)])` + * * `count(string_custom_attribute["some-string-custom-attribute"])` + * * `count(numeric_custom_attribute["some-numeric-custom-attribute"], + * [bucket(MIN, 0, "negative"), bucket(0, MAX, "non-negative")])` + * @param {google.cloud.talent.v4beta1.JobView} request.jobView + * The desired job attributes returned for jobs in the search response. + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_SMALL|JobView.JOB_VIEW_SMALL} + * if no value is specified. + * @param {number} request.offset + * An integer that specifies the current offset (that is, starting result + * location, amongst the jobs deemed by the API as relevant) in search + * results. This field is only considered if + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.page_token|page_token} is + * unset. + * + * The maximum allowed value is 5000. Otherwise an error is thrown. + * + * For example, 0 means to return results starting from the first matching + * job, and 10 means to return from the 11th job. This can be used for + * pagination, (for example, pageSize = 10 and offset = 10 means to return + * from the second page). + * @param {number} request.pageSize + * A limit on the number of jobs returned in the search results. + * Increasing this value above the default value of 10 can increase search + * response time. The value can be between 1 and 100. + * @param {string} request.pageToken + * The token specifying the current offset within + * search results. See + * {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse.next_page_token|SearchJobsResponse.next_page_token} + * for an explanation of how to obtain the next set of query results. + * @param {string} request.orderBy + * The criteria determining how search results are sorted. Default is + * `"relevance desc"`. + * + * Supported options are: + * + * * `"relevance desc"`: By relevance descending, as determined by the API + * algorithms. Relevance thresholding of query results is only available + * with this ordering. + * * `"posting_publish_time desc"`: By + * {@link protos.google.cloud.talent.v4beta1.Job.posting_publish_time|Job.posting_publish_time} + * descending. + * * `"posting_update_time desc"`: By + * {@link protos.google.cloud.talent.v4beta1.Job.posting_update_time|Job.posting_update_time} + * descending. + * * `"title"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} + * ascending. + * * `"title desc"`: By {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title} + * descending. + * * `"annualized_base_compensation"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_base_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_base_compensation_range|CompensationInfo.annualized_base_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"annualized_total_compensation"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * ascending. Jobs whose annualized base compensation is unspecified are put + * at the end of search results. + * * `"annualized_total_compensation desc"`: By job's + * {@link protos.google.cloud.talent.v4beta1.CompensationInfo.annualized_total_compensation_range|CompensationInfo.annualized_total_compensation_range} + * descending. Jobs whose annualized base compensation is unspecified are + * put at the end of search results. + * * `"custom_ranking desc"`: By the relevance score adjusted to the + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.ranking_expression|SearchJobsRequest.CustomRankingInfo.ranking_expression} + * with weight factor assigned by + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo.importance_level|SearchJobsRequest.CustomRankingInfo.importance_level} + * in descending order. + * * Location sorting: Use the special syntax to order jobs by distance:
+ * `"distance_from('Hawaii')"`: Order by distance from Hawaii.
+ * `"distance_from(19.89, 155.5)"`: Order by distance from a coordinate.
+ * `"distance_from('Hawaii'), distance_from('Puerto Rico')"`: Order by + * multiple locations. See details below.
+ * `"distance_from('Hawaii'), distance_from(19.89, 155.5)"`: Order by + * multiple locations. See details below.
+ * The string can have a maximum of 256 characters. When multiple distance + * centers are provided, a job that is close to any of the distance centers + * would have a high rank. When a job has multiple locations, the job + * location closest to one of the distance centers will be used. Jobs that + * don't have locations will be ranked at the bottom. Distance is calculated + * with a precision of 11.3 meters (37.4 feet). Diversification strategy is + * still applied unless explicitly disabled in + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.diversification_level|diversification_level}. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel} request.diversificationLevel + * Controls whether highly similar jobs are returned next to each other in + * the search results. Jobs are identified as highly similar based on + * their titles, job categories, and locations. Highly similar results are + * clustered so that only one representative job of the cluster is + * displayed to the job seeker higher up in the results, with the other jobs + * being displayed lower down in the results. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.DiversificationLevel.SIMPLE|DiversificationLevel.SIMPLE} + * if no value is specified. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.CustomRankingInfo} request.customRankingInfo + * Controls over how job documents get ranked on top of existing relevance + * score (determined by API algorithm). + * @param {boolean} request.disableKeywordMatch + * This field is deprecated. Please use + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * going forward. + * + * To migrate, disable_keyword_match set to false maps to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL}, + * and disable_keyword_match set to true maps to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_DISABLED|KeywordMatchMode.KEYWORD_MATCH_DISABLED}. + * If + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.keyword_match_mode|SearchJobsRequest.keyword_match_mode} + * is set, this field is ignored. + * + * Controls whether to disable exact keyword match on + * {@link protos.google.cloud.talent.v4beta1.Job.title|Job.title}, + * {@link protos.google.cloud.talent.v4beta1.Job.description|Job.description}, + * {@link protos.google.cloud.talent.v4beta1.Job.company_display_name|Job.company_display_name}, + * {@link protos.google.cloud.talent.v4beta1.Job.addresses|Job.addresses}, + * {@link protos.google.cloud.talent.v4beta1.Job.qualifications|Job.qualifications}. When + * disable keyword match is turned off, a keyword match returns jobs that do + * not match given category filters when there are matching keywords. For + * example, for the query "program manager," a result is returned even if the + * job posting has the title "software developer," which doesn't fall into + * "program manager" ontology, but does have "program manager" appearing in + * its description. + * + * For queries like "cloud" that don't contain title or + * location specific ontology, jobs with "cloud" keyword matches are returned + * regardless of this flag's value. + * + * Use + * {@link protos.google.cloud.talent.v4beta1.Company.keyword_searchable_job_custom_attributes|Company.keyword_searchable_job_custom_attributes} + * if company-specific globally matched custom field/attribute string values + * are needed. Enabling keyword match improves recall of subsequent search + * requests. + * + * Defaults to false. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode} request.keywordMatchMode + * Controls what keyword match options to use. + * + * Defaults to + * {@link protos.google.cloud.talent.v4beta1.SearchJobsRequest.KeywordMatchMode.KEYWORD_MATCH_ALL|KeywordMatchMode.KEYWORD_MATCH_ALL} + * if no value is specified. + * @param {google.cloud.talent.v4beta1.SearchJobsRequest.RelevanceThreshold} [request.relevanceThreshold] + * Optional. The relevance threshold of the search results. + * + * Default to Google defined threshold, leveraging a balance of + * precision and recall to deliver both highly accurate results and + * comprehensive coverage of relevant information. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.SearchJobsResponse|SearchJobsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.search_jobs_for_alert.js + * region_tag:jobs_v4beta1_generated_JobService_SearchJobsForAlert_async + */ searchJobsForAlert( - request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ] + >; searchJobsForAlert( - request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobsForAlert( - request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): void; searchJobsForAlert( - request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.ISearchJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ISearchJobsRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('searchJobsForAlert request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + | protos.google.cloud.talent.v4beta1.ISearchJobsRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('searchJobsForAlert response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.searchJobsForAlert(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ISearchJobsResponse, - protos.google.cloud.talent.v4beta1.ISearchJobsRequest|undefined, - {}|undefined - ]) => { - this._log.info('searchJobsForAlert response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .searchJobsForAlert(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ISearchJobsResponse, + protos.google.cloud.talent.v4beta1.ISearchJobsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('searchJobsForAlert response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Begins executing a batch create jobs operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {number[]} request.jobs - * Required. The jobs 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/v4beta1/job_service.batch_create_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_BatchCreateJobs_async - */ + /** + * Begins executing a batch create jobs operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {number[]} request.jobs + * Required. The jobs 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/v4beta1/job_service.batch_create_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_BatchCreateJobs_async + */ batchCreateJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchCreateJobs( - request: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchCreateJobs( - request: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchCreateJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.talent.v4beta1.IBatchCreateJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchCreateJobs response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchCreateJobs request %j', request); - return this.innerApiCalls.batchCreateJobs(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchCreateJobs response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchCreateJobs(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchCreateJobs response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchCreateJobs()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.batch_create_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_BatchCreateJobs_async - */ - async checkBatchCreateJobsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchCreateJobs()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.batch_create_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_BatchCreateJobs_async + */ + async checkBatchCreateJobsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.talent.v4beta1.JobOperationResult, + protos.google.cloud.talent.v4beta1.BatchOperationMetadata + > + > { this._log.info('batchCreateJobs long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchCreateJobs, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchCreateJobs, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.talent.v4beta1.JobOperationResult, + protos.google.cloud.talent.v4beta1.BatchOperationMetadata + >; } -/** - * Begins executing a batch update jobs operation. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {number[]} request.jobs - * Required. The jobs to be updated. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. Be aware that it will - * also increase latency when checking the status of a batch operation. - * - * If - * {@link protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} - * is provided, only the specified fields in - * {@link protos.google.cloud.talent.v4beta1.Job|Job} are updated. Otherwise all the - * fields are updated. - * - * A field mask to restrict the fields that are updated. Only - * top level fields of {@link protos.google.cloud.talent.v4beta1.Job|Job} are supported. - * - * If - * {@link protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} - * is provided, The {@link protos.google.cloud.talent.v4beta1.Job|Job} inside - * {@link protos.google.cloud.talent.v4beta1.JobOperationResult.JobResult|JobResult} - * will only contains fields that is updated, plus the Id of the Job. - * Otherwise, {@link protos.google.cloud.talent.v4beta1.Job|Job} will include all fields, - * which can yield a very large 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 an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.batch_update_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_BatchUpdateJobs_async - */ + /** + * Begins executing a batch update jobs operation. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {number[]} request.jobs + * Required. The jobs to be updated. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. Be aware that it will + * also increase latency when checking the status of a batch operation. + * + * If + * {@link protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} + * is provided, only the specified fields in + * {@link protos.google.cloud.talent.v4beta1.Job|Job} are updated. Otherwise all the + * fields are updated. + * + * A field mask to restrict the fields that are updated. Only + * top level fields of {@link protos.google.cloud.talent.v4beta1.Job|Job} are supported. + * + * If + * {@link protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest.update_mask|update_mask} + * is provided, The {@link protos.google.cloud.talent.v4beta1.Job|Job} inside + * {@link protos.google.cloud.talent.v4beta1.JobOperationResult.JobResult|JobResult} + * will only contains fields that is updated, plus the Id of the Job. + * Otherwise, {@link protos.google.cloud.talent.v4beta1.Job|Job} will include all fields, + * which can yield a very large 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 an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.batch_update_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_BatchUpdateJobs_async + */ batchUpdateJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; batchUpdateJobs( - request: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchUpdateJobs( - request: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, + callback: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; batchUpdateJobs( - request?: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.cloud.talent.v4beta1.IBatchUpdateJobsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, rawResponse, _) => { this._log.info('batchUpdateJobs response %j', rawResponse); callback!(error, response, rawResponse, _); // We verified callback above. } : undefined; this._log.info('batchUpdateJobs request %j', request); - return this.innerApiCalls.batchUpdateJobs(request, options, wrappedCallback) - ?.then(([response, rawResponse, _]: [ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]) => { - this._log.info('batchUpdateJobs response %j', rawResponse); - return [response, rawResponse, _]; - }); + return this.innerApiCalls + .batchUpdateJobs(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('batchUpdateJobs response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); } -/** - * Check the status of the long running operation returned by `batchUpdateJobs()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/job_service.batch_update_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_BatchUpdateJobs_async - */ - async checkBatchUpdateJobsProgress(name: string): Promise>{ + /** + * Check the status of the long running operation returned by `batchUpdateJobs()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/job_service.batch_update_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_BatchUpdateJobs_async + */ + async checkBatchUpdateJobsProgress( + name: string, + ): Promise< + LROperation< + protos.google.cloud.talent.v4beta1.JobOperationResult, + protos.google.cloud.talent.v4beta1.BatchOperationMetadata + > + > { this._log.info('batchUpdateJobs long-running'); - const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({name}); + const request = + new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest( + { name }, + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.batchUpdateJobs, this._gaxModule.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new this._gaxModule.Operation( + operation, + this.descriptors.longrunning.batchUpdateJobs, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.cloud.talent.v4beta1.JobOperationResult, + protos.google.cloud.talent.v4beta1.BatchOperationMetadata + >; } - /** - * Lists jobs by filter. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The resource name of the tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set - * to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4beta1.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} - * if no value is specified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.talent.v4beta1.Job|Job}. - * 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 jobs by filter. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set + * to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4beta1.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} + * if no value is specified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.talent.v4beta1.Job|Job}. + * 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobs( - request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob[], - protos.google.cloud.talent.v4beta1.IListJobsRequest|null, - protos.google.cloud.talent.v4beta1.IListJobsResponse - ]>; + request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob[], + protos.google.cloud.talent.v4beta1.IListJobsRequest | null, + protos.google.cloud.talent.v4beta1.IListJobsResponse, + ] + >; listJobs( - request: protos.google.cloud.talent.v4beta1.IListJobsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListJobsRequest, - protos.google.cloud.talent.v4beta1.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.IJob>): void; + request: protos.google.cloud.talent.v4beta1.IListJobsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListJobsRequest, + protos.google.cloud.talent.v4beta1.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4beta1.IJob + >, + ): void; listJobs( - request: protos.google.cloud.talent.v4beta1.IListJobsRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListJobsRequest, - protos.google.cloud.talent.v4beta1.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.IJob>): void; + request: protos.google.cloud.talent.v4beta1.IListJobsRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListJobsRequest, + protos.google.cloud.talent.v4beta1.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4beta1.IJob + >, + ): void; listJobs( - request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.talent.v4beta1.IListJobsRequest, - protos.google.cloud.talent.v4beta1.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.IJob>, - callback?: PaginationCallback< + request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4beta1.IListJobsRequest, - protos.google.cloud.talent.v4beta1.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.IJob>): - Promise<[ - protos.google.cloud.talent.v4beta1.IJob[], - protos.google.cloud.talent.v4beta1.IListJobsRequest|null, - protos.google.cloud.talent.v4beta1.IListJobsResponse - ]>|void { + | protos.google.cloud.talent.v4beta1.IListJobsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.IJob + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListJobsRequest, + protos.google.cloud.talent.v4beta1.IListJobsResponse | null | undefined, + protos.google.cloud.talent.v4beta1.IJob + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.IJob[], + protos.google.cloud.talent.v4beta1.IListJobsRequest | null, + protos.google.cloud.talent.v4beta1.IListJobsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4beta1.IListJobsRequest, - protos.google.cloud.talent.v4beta1.IListJobsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.IJob>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4beta1.IListJobsRequest, + | protos.google.cloud.talent.v4beta1.IListJobsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.IJob + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listJobs values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -2059,191 +2520,195 @@ export class JobServiceClient { this._log.info('listJobs request %j', request); return this.innerApiCalls .listJobs(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4beta1.IJob[], - protos.google.cloud.talent.v4beta1.IListJobsRequest|null, - protos.google.cloud.talent.v4beta1.IListJobsResponse - ]) => { - this._log.info('listJobs values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4beta1.IJob[], + protos.google.cloud.talent.v4beta1.IListJobsRequest | null, + protos.google.cloud.talent.v4beta1.IListJobsResponse, + ]) => { + this._log.info('listJobs values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listJobs`, 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 tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set - * to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4beta1.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} - * if no value is specified. - * @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.talent.v4beta1.Job|Job} 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 `listJobsAsync()` - * method described below for async iteration which you can stop as 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 `listJobs`, 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 tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set + * to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4beta1.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} + * if no value is specified. + * @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.talent.v4beta1.Job|Job} 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 `listJobsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listJobsStream( - request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs stream %j', request); return this.descriptors.page.listJobs.createStream( this.innerApiCalls.listJobs as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listJobs`, 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 tenant under which the job is created. - * - * The format is "projects/{project_id}/tenants/{tenant_id}". For example, - * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant - * is created. For example, "projects/foo". - * @param {string} request.filter - * Required. The filter string specifies the jobs to be enumerated. - * - * Supported operator: =, AND - * - * The fields eligible for filtering are: - * - * * `companyName` - * * `requisitionId` - * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to - * OPEN if no value is specified. - * - * At least one of `companyName` and `requisitionId` must present or an - * INVALID_ARGUMENT error is thrown. - * - * Sample Query: - * - * * companyName = "projects/foo/tenants/bar/companies/baz" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * requisitionId = "req-1" - * * companyName = "projects/foo/tenants/bar/companies/baz" AND - * status = "EXPIRED" - * * requisitionId = "req-1" - * * requisitionId = "req-1" AND status = "EXPIRED" - * @param {string} request.pageToken - * The starting point of a query result. - * @param {number} request.pageSize - * The maximum number of jobs to be returned per page of results. - * - * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set - * to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, - * the maximum allowed page size is 1000. Otherwise, the maximum allowed page - * size is 100. - * - * Default is 100 if empty or a number < 1 is specified. - * @param {google.cloud.talent.v4beta1.JobView} request.jobView - * The desired job attributes returned for jobs in the - * search response. Defaults to - * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} - * if no value is specified. - * @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.talent.v4beta1.Job|Job}. 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/v4beta1/job_service.list_jobs.js - * region_tag:jobs_v4beta1_generated_JobService_ListJobs_async - */ + /** + * Equivalent to `listJobs`, 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 tenant under which the job is created. + * + * The format is "projects/{project_id}/tenants/{tenant_id}". For example, + * "projects/foo/tenant/bar". If tenant id is unspecified, a default tenant + * is created. For example, "projects/foo". + * @param {string} request.filter + * Required. The filter string specifies the jobs to be enumerated. + * + * Supported operator: =, AND + * + * The fields eligible for filtering are: + * + * * `companyName` + * * `requisitionId` + * * `status` Available values: OPEN, EXPIRED, ALL. Defaults to + * OPEN if no value is specified. + * + * At least one of `companyName` and `requisitionId` must present or an + * INVALID_ARGUMENT error is thrown. + * + * Sample Query: + * + * * companyName = "projects/foo/tenants/bar/companies/baz" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * requisitionId = "req-1" + * * companyName = "projects/foo/tenants/bar/companies/baz" AND + * status = "EXPIRED" + * * requisitionId = "req-1" + * * requisitionId = "req-1" AND status = "EXPIRED" + * @param {string} request.pageToken + * The starting point of a query result. + * @param {number} request.pageSize + * The maximum number of jobs to be returned per page of results. + * + * If {@link protos.google.cloud.talent.v4beta1.ListJobsRequest.job_view|job_view} is set + * to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_ID_ONLY|JobView.JOB_VIEW_ID_ONLY}, + * the maximum allowed page size is 1000. Otherwise, the maximum allowed page + * size is 100. + * + * Default is 100 if empty or a number < 1 is specified. + * @param {google.cloud.talent.v4beta1.JobView} request.jobView + * The desired job attributes returned for jobs in the + * search response. Defaults to + * {@link protos.google.cloud.talent.v4beta1.JobView.JOB_VIEW_FULL|JobView.JOB_VIEW_FULL} + * if no value is specified. + * @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.talent.v4beta1.Job|Job}. 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/v4beta1/job_service.list_jobs.js + * region_tag:jobs_v4beta1_generated_JobService_ListJobs_async + */ listJobsAsync( - request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4beta1.IListJobsRequest, + 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['listJobs']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listJobs iterate %j', request); return this.descriptors.page.listJobs.asyncIterate( this.innerApiCalls['listJobs'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + /** * 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. @@ -2286,22 +2751,22 @@ export class JobServiceClient { 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); } /** @@ -2336,15 +2801,15 @@ export class JobServiceClient { */ 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); } /** @@ -2378,7 +2843,7 @@ export class JobServiceClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: | gax.CallOptions @@ -2391,25 +2856,24 @@ export class JobServiceClient { 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 @@ -2448,22 +2912,22 @@ export class JobServiceClient { 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); } @@ -2477,7 +2941,7 @@ export class JobServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2501,7 +2965,7 @@ export class JobServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectCompanyPath(project:string,company:string) { + projectCompanyPath(project: string, company: string) { return this.pathTemplates.projectCompanyPathTemplate.render({ project: project, company: company, @@ -2516,7 +2980,9 @@ export class JobServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).project; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).project; } /** @@ -2527,7 +2993,9 @@ export class JobServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).company; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).company; } /** @@ -2537,7 +3005,7 @@ export class JobServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectJobPath(project:string,job:string) { + projectJobPath(project: string, job: string) { return this.pathTemplates.projectJobPathTemplate.render({ project: project, job: job, @@ -2552,7 +3020,8 @@ export class JobServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectJobName(projectJobName: string) { - return this.pathTemplates.projectJobPathTemplate.match(projectJobName).project; + return this.pathTemplates.projectJobPathTemplate.match(projectJobName) + .project; } /** @@ -2574,7 +3043,7 @@ export class JobServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectTenantCompanyPath(project:string,tenant:string,company:string) { + projectTenantCompanyPath(project: string, tenant: string, company: string) { return this.pathTemplates.projectTenantCompanyPathTemplate.render({ project: project, tenant: tenant, @@ -2590,7 +3059,9 @@ export class JobServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).project; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).project; } /** @@ -2601,7 +3072,9 @@ export class JobServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).tenant; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).tenant; } /** @@ -2612,7 +3085,9 @@ export class JobServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).company; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).company; } /** @@ -2623,7 +3098,7 @@ export class JobServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectTenantJobPath(project:string,tenant:string,job:string) { + projectTenantJobPath(project: string, tenant: string, job: string) { return this.pathTemplates.projectTenantJobPathTemplate.render({ project: project, tenant: tenant, @@ -2639,7 +3114,9 @@ export class JobServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).project; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).project; } /** @@ -2650,7 +3127,9 @@ export class JobServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).tenant; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).tenant; } /** @@ -2661,7 +3140,9 @@ export class JobServiceClient { * @returns {string} A string representing the job. */ matchJobFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).job; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).job; } /** @@ -2671,7 +3152,7 @@ export class JobServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -2708,7 +3189,7 @@ export class JobServiceClient { */ close(): Promise { if (this.jobServiceStub && !this._terminated) { - return this.jobServiceStub.then(stub => { + return this.jobServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -2717,4 +3198,4 @@ export class JobServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts b/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts index d473d9c34975..b17c7a384e93 100644 --- a/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts +++ b/packages/google-cloud-talent/src/v4beta1/tenant_service_client.ts @@ -18,11 +18,18 @@ /* global window */ import type * as gax from 'google-gax'; -import type {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; -import {Transform} from 'stream'; +import type { + Callback, + CallOptions, + Descriptors, + ClientOptions, + 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 +51,7 @@ export class TenantServiceClient { 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('talent'); @@ -57,9 +64,9 @@ export class TenantServiceClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - tenantServiceStub?: Promise<{[name: string]: Function}>; + innerApiCalls: { [name: string]: Function }; + pathTemplates: { [name: string]: gax.PathTemplate }; + tenantServiceStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of TenantServiceClient. @@ -100,21 +107,42 @@ export class TenantServiceClient { * const client = new TenantServiceClient({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 TenantServiceClient; - 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 = 'jobs.' + 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; @@ -139,7 +167,7 @@ export class TenantServiceClient { 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; @@ -153,10 +181,7 @@ export class TenantServiceClient { } // 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 { @@ -178,22 +203,22 @@ export class TenantServiceClient { // Create useful helper objects for these. this.pathTemplates = { projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), projectCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/companies/{company}' + 'projects/{project}/companies/{company}', ), projectJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/jobs/{job}' + 'projects/{project}/jobs/{job}', ), projectTenantCompanyPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/companies/{company}' + 'projects/{project}/tenants/{tenant}/companies/{company}', ), projectTenantJobPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}/jobs/{job}' + 'projects/{project}/tenants/{tenant}/jobs/{job}', ), tenantPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/tenants/{tenant}' + 'projects/{project}/tenants/{tenant}', ), }; @@ -201,14 +226,20 @@ export class TenantServiceClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTenants: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tenants') + listTenants: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tenants', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.talent.v4beta1.TenantService', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.talent.v4beta1.TenantService', + 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 @@ -239,37 +270,46 @@ export class TenantServiceClient { // Put together the "service stub" for // google.cloud.talent.v4beta1.TenantService. this.tenantServiceStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.talent.v4beta1.TenantService') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.talent.v4beta1.TenantService', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.talent.v4beta1.TenantService, - 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 tenantServiceStubMethods = - ['createTenant', 'getTenant', 'updateTenant', 'deleteTenant', 'listTenants']; + const tenantServiceStubMethods = [ + 'createTenant', + 'getTenant', + 'updateTenant', + 'deleteTenant', + 'listTenants', + ]; for (const methodName of tenantServiceStubMethods) { const callPromise = this.tenantServiceStub.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; @@ -284,8 +324,14 @@ export class TenantServiceClient { * @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 'jobs.googleapis.com'; } @@ -296,8 +342,14 @@ export class TenantServiceClient { * @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 'jobs.googleapis.com'; } @@ -330,7 +382,7 @@ export class TenantServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/jobs' + 'https://www.googleapis.com/auth/jobs', ]; } @@ -340,8 +392,9 @@ export class TenantServiceClient { * 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; @@ -352,492 +405,671 @@ export class TenantServiceClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new tenant entity. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {google.cloud.talent.v4beta1.Tenant} request.tenant - * Required. The tenant 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 {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/tenant_service.create_tenant.js - * region_tag:jobs_v4beta1_generated_TenantService_CreateTenant_async - */ + /** + * Creates a new tenant entity. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {google.cloud.talent.v4beta1.Tenant} request.tenant + * Required. The tenant 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 {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/tenant_service.create_tenant.js + * region_tag:jobs_v4beta1_generated_TenantService_CreateTenant_async + */ createTenant( - request?: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.ICreateTenantRequest | undefined, + {} | undefined, + ] + >; createTenant( - request: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.ICreateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTenant( - request: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.ICreateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; createTenant( - request?: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, - optionsOrCallback?: CallOptions|Callback< + request?: protos.google.cloud.talent.v4beta1.ICreateTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.ICreateTenantRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.ICreateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.ICreateTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.ICreateTenantRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.createTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.ICreateTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('createTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.ICreateTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Retrieves specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the tenant to be retrieved. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/tenant_service.get_tenant.js - * region_tag:jobs_v4beta1_generated_TenantService_GetTenant_async - */ + /** + * Retrieves specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the tenant to be retrieved. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/tenant_service.get_tenant.js + * region_tag:jobs_v4beta1_generated_TenantService_GetTenant_async + */ getTenant( - request?: protos.google.cloud.talent.v4beta1.IGetTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IGetTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | undefined, + {} | undefined, + ] + >; getTenant( - request: protos.google.cloud.talent.v4beta1.IGetTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; getTenant( - request: protos.google.cloud.talent.v4beta1.IGetTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IGetTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): void; getTenant( - request?: protos.google.cloud.talent.v4beta1.IGetTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IGetTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IGetTenantRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.IGetTenantRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.getTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IGetTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('getTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IGetTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.talent.v4beta1.Tenant} request.tenant - * Required. The tenant resource to replace the current resource in the - * system. - * @param {google.protobuf.FieldMask} request.updateMask - * Strongly recommended for the best service experience. - * - * If - * {@link protos.google.cloud.talent.v4beta1.UpdateTenantRequest.update_mask|update_mask} - * is provided, only the specified fields in - * {@link protos.google.cloud.talent.v4beta1.UpdateTenantRequest.tenant|tenant} are - * updated. Otherwise all the fields are updated. - * - * A field mask to specify the tenant fields to be updated. Only - * top level fields of {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant} are - * 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 {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v4beta1/tenant_service.update_tenant.js - * region_tag:jobs_v4beta1_generated_TenantService_UpdateTenant_async - */ + /** + * Updates specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.talent.v4beta1.Tenant} request.tenant + * Required. The tenant resource to replace the current resource in the + * system. + * @param {google.protobuf.FieldMask} request.updateMask + * Strongly recommended for the best service experience. + * + * If + * {@link protos.google.cloud.talent.v4beta1.UpdateTenantRequest.update_mask|update_mask} + * is provided, only the specified fields in + * {@link protos.google.cloud.talent.v4beta1.UpdateTenantRequest.tenant|tenant} are + * updated. Otherwise all the fields are updated. + * + * A field mask to specify the tenant fields to be updated. Only + * top level fields of {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant} are + * 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 {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v4beta1/tenant_service.update_tenant.js + * region_tag:jobs_v4beta1_generated_TenantService_UpdateTenant_async + */ updateTenant( - request?: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IUpdateTenantRequest | undefined, + {} | undefined, + ] + >; updateTenant( - request: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.IUpdateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTenant( - request: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, - callback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, + callback: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.IUpdateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; updateTenant( - request?: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IUpdateTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IUpdateTenantRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.IUpdateTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IUpdateTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'tenant.name': request.tenant!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'tenant.name': request.tenant!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateTenant request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.talent.v4beta1.ITenant, + | protos.google.cloud.talent.v4beta1.IUpdateTenantRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.updateTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.talent.v4beta1.ITenant, - protos.google.cloud.talent.v4beta1.IUpdateTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('updateTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.talent.v4beta1.ITenant, + protos.google.cloud.talent.v4beta1.IUpdateTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 specified tenant. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the tenant to be deleted. - * - * The format is "projects/{project_id}/tenants/{tenant_id}", for example, - * "projects/foo/tenants/bar". - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/tenant_service.delete_tenant.js - * region_tag:jobs_v4beta1_generated_TenantService_DeleteTenant_async - */ + /** + * Deletes specified tenant. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the tenant to be deleted. + * + * The format is "projects/{project_id}/tenants/{tenant_id}", for example, + * "projects/foo/tenants/bar". + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v4beta1/tenant_service.delete_tenant.js + * region_tag:jobs_v4beta1_generated_TenantService_DeleteTenant_async + */ deleteTenant( - request?: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteTenantRequest | undefined, + {} | undefined, + ] + >; deleteTenant( - request: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTenant( - request: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): void; deleteTenant( - request?: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.talent.v4beta1.IDeleteTenantRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.talent.v4beta1.IDeleteTenantRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteTenantRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteTenantRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTenant request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.talent.v4beta1.IDeleteTenantRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTenant response %j', response); callback!(error, response, options, rawResponse); // We verified callback above. } : undefined; - return this.innerApiCalls.deleteTenant(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.talent.v4beta1.IDeleteTenantRequest|undefined, - {}|undefined - ]) => { - this._log.info('deleteTenant response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteTenant(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.talent.v4beta1.IDeleteTenantRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTenant response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 all tenants associated with the project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number 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 Array of {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. - * 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 `listTenantsAsync()` - * method described below for async iteration which you can stop as 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 tenants associated with the project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number 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 Array of {@link protos.google.cloud.talent.v4beta1.Tenant|Tenant}. + * 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 `listTenantsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTenants( - request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant[], - protos.google.cloud.talent.v4beta1.IListTenantsRequest|null, - protos.google.cloud.talent.v4beta1.IListTenantsResponse - ]>; + request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant[], + protos.google.cloud.talent.v4beta1.IListTenantsRequest | null, + protos.google.cloud.talent.v4beta1.IListTenantsResponse, + ] + >; listTenants( - request: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListTenantsRequest, - protos.google.cloud.talent.v4beta1.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ITenant>): void; + request: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListTenantsRequest, + | protos.google.cloud.talent.v4beta1.IListTenantsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ITenant + >, + ): void; listTenants( - request: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - callback: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListTenantsRequest, - protos.google.cloud.talent.v4beta1.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ITenant>): void; + request: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + callback: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListTenantsRequest, + | protos.google.cloud.talent.v4beta1.IListTenantsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ITenant + >, + ): void; listTenants( - request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.talent.v4beta1.IListTenantsRequest, - protos.google.cloud.talent.v4beta1.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ITenant>, - callback?: PaginationCallback< - protos.google.cloud.talent.v4beta1.IListTenantsRequest, - protos.google.cloud.talent.v4beta1.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ITenant>): - Promise<[ - protos.google.cloud.talent.v4beta1.ITenant[], - protos.google.cloud.talent.v4beta1.IListTenantsRequest|null, - protos.google.cloud.talent.v4beta1.IListTenantsResponse - ]>|void { + | protos.google.cloud.talent.v4beta1.IListTenantsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ITenant + >, + callback?: PaginationCallback< + protos.google.cloud.talent.v4beta1.IListTenantsRequest, + | protos.google.cloud.talent.v4beta1.IListTenantsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ITenant + >, + ): Promise< + [ + protos.google.cloud.talent.v4beta1.ITenant[], + protos.google.cloud.talent.v4beta1.IListTenantsRequest | null, + protos.google.cloud.talent.v4beta1.IListTenantsResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.talent.v4beta1.IListTenantsRequest, - protos.google.cloud.talent.v4beta1.IListTenantsResponse|null|undefined, - protos.google.cloud.talent.v4beta1.ITenant>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.talent.v4beta1.IListTenantsRequest, + | protos.google.cloud.talent.v4beta1.IListTenantsResponse + | null + | undefined, + protos.google.cloud.talent.v4beta1.ITenant + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTenants values %j', values); callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. @@ -846,114 +1078,118 @@ export class TenantServiceClient { this._log.info('listTenants request %j', request); return this.innerApiCalls .listTenants(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.talent.v4beta1.ITenant[], - protos.google.cloud.talent.v4beta1.IListTenantsRequest|null, - protos.google.cloud.talent.v4beta1.IListTenantsResponse - ]) => { - this._log.info('listTenants values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.talent.v4beta1.ITenant[], + protos.google.cloud.talent.v4beta1.IListTenantsRequest | null, + protos.google.cloud.talent.v4beta1.IListTenantsResponse, + ]) => { + this._log.info('listTenants values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTenants`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @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.talent.v4beta1.Tenant|Tenant} 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 `listTenantsAsync()` - * method described below for async iteration which you can stop as 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 `listTenants`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @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.talent.v4beta1.Tenant|Tenant} 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 `listTenantsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTenantsStream( - request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + 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['listTenants']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTenants stream %j', request); return this.descriptors.page.listTenants.createStream( this.innerApiCalls.listTenants as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTenants`, 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. Resource name of the project under which the tenant is created. - * - * The format is "projects/{project_id}", for example, - * "projects/foo". - * @param {string} request.pageToken - * The starting indicator from which to return results. - * @param {number} request.pageSize - * The maximum number of tenants to be returned, at most 100. - * Default is 100 if a non-positive number is provided. - * @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.talent.v4beta1.Tenant|Tenant}. 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/v4beta1/tenant_service.list_tenants.js - * region_tag:jobs_v4beta1_generated_TenantService_ListTenants_async - */ + /** + * Equivalent to `listTenants`, 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. Resource name of the project under which the tenant is created. + * + * The format is "projects/{project_id}", for example, + * "projects/foo". + * @param {string} request.pageToken + * The starting indicator from which to return results. + * @param {number} request.pageSize + * The maximum number of tenants to be returned, at most 100. + * Default is 100 if a non-positive number is provided. + * @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.talent.v4beta1.Tenant|Tenant}. 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/v4beta1/tenant_service.list_tenants.js + * region_tag:jobs_v4beta1_generated_TenantService_ListTenants_async + */ listTenantsAsync( - request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.talent.v4beta1.IListTenantsRequest, + 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['listTenants']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTenants iterate %j', request); return this.descriptors.page.listTenants.asyncIterate( this.innerApiCalls['listTenants'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } // -------------------- @@ -966,7 +1202,7 @@ export class TenantServiceClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -990,7 +1226,7 @@ export class TenantServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectCompanyPath(project:string,company:string) { + projectCompanyPath(project: string, company: string) { return this.pathTemplates.projectCompanyPathTemplate.render({ project: project, company: company, @@ -1005,7 +1241,9 @@ export class TenantServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).project; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).project; } /** @@ -1016,7 +1254,9 @@ export class TenantServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectCompanyName(projectCompanyName: string) { - return this.pathTemplates.projectCompanyPathTemplate.match(projectCompanyName).company; + return this.pathTemplates.projectCompanyPathTemplate.match( + projectCompanyName, + ).company; } /** @@ -1026,7 +1266,7 @@ export class TenantServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectJobPath(project:string,job:string) { + projectJobPath(project: string, job: string) { return this.pathTemplates.projectJobPathTemplate.render({ project: project, job: job, @@ -1041,7 +1281,8 @@ export class TenantServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectJobName(projectJobName: string) { - return this.pathTemplates.projectJobPathTemplate.match(projectJobName).project; + return this.pathTemplates.projectJobPathTemplate.match(projectJobName) + .project; } /** @@ -1063,7 +1304,7 @@ export class TenantServiceClient { * @param {string} company * @returns {string} Resource name string. */ - projectTenantCompanyPath(project:string,tenant:string,company:string) { + projectTenantCompanyPath(project: string, tenant: string, company: string) { return this.pathTemplates.projectTenantCompanyPathTemplate.render({ project: project, tenant: tenant, @@ -1079,7 +1320,9 @@ export class TenantServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).project; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).project; } /** @@ -1090,7 +1333,9 @@ export class TenantServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).tenant; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).tenant; } /** @@ -1101,7 +1346,9 @@ export class TenantServiceClient { * @returns {string} A string representing the company. */ matchCompanyFromProjectTenantCompanyName(projectTenantCompanyName: string) { - return this.pathTemplates.projectTenantCompanyPathTemplate.match(projectTenantCompanyName).company; + return this.pathTemplates.projectTenantCompanyPathTemplate.match( + projectTenantCompanyName, + ).company; } /** @@ -1112,7 +1359,7 @@ export class TenantServiceClient { * @param {string} job * @returns {string} Resource name string. */ - projectTenantJobPath(project:string,tenant:string,job:string) { + projectTenantJobPath(project: string, tenant: string, job: string) { return this.pathTemplates.projectTenantJobPathTemplate.render({ project: project, tenant: tenant, @@ -1128,7 +1375,9 @@ export class TenantServiceClient { * @returns {string} A string representing the project. */ matchProjectFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).project; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).project; } /** @@ -1139,7 +1388,9 @@ export class TenantServiceClient { * @returns {string} A string representing the tenant. */ matchTenantFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).tenant; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).tenant; } /** @@ -1150,7 +1401,9 @@ export class TenantServiceClient { * @returns {string} A string representing the job. */ matchJobFromProjectTenantJobName(projectTenantJobName: string) { - return this.pathTemplates.projectTenantJobPathTemplate.match(projectTenantJobName).job; + return this.pathTemplates.projectTenantJobPathTemplate.match( + projectTenantJobName, + ).job; } /** @@ -1160,7 +1413,7 @@ export class TenantServiceClient { * @param {string} tenant * @returns {string} Resource name string. */ - tenantPath(project:string,tenant:string) { + tenantPath(project: string, tenant: string) { return this.pathTemplates.tenantPathTemplate.render({ project: project, tenant: tenant, @@ -1197,7 +1450,7 @@ export class TenantServiceClient { */ close(): Promise { if (this.tenantServiceStub && !this._terminated) { - return this.tenantServiceStub.then(stub => { + return this.tenantServiceStub.then((stub) => { this._log.info('ending gRPC channel'); this._terminated = true; stub.close(); @@ -1205,4 +1458,4 @@ export class TenantServiceClient { } return Promise.resolve(); } -} \ No newline at end of file +} diff --git a/packages/google-cloud-talent/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-talent/system-test/fixtures/sample/src/index.ts index 87900fee2133..82ad6e825423 100644 --- a/packages/google-cloud-talent/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-talent/system-test/fixtures/sample/src/index.ts @@ -16,7 +16,13 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CompanyServiceClient, CompletionClient, EventServiceClient, JobServiceClient, TenantServiceClient} from '@google-cloud/talent'; +import { + CompanyServiceClient, + CompletionClient, + EventServiceClient, + JobServiceClient, + TenantServiceClient, +} from '@google-cloud/talent'; // check that the client class type name can be used function doStuffWithCompanyServiceClient(client: CompanyServiceClient) { diff --git a/packages/google-cloud-talent/system-test/install.ts b/packages/google-cloud-talent/system-test/install.ts index f66069aa3940..ccf167042d2e 100644 --- a/packages/google-cloud-talent/system-test/install.ts +++ b/packages/google-cloud-talent/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-talent/test/gapic_company_service_v4.ts b/packages/google-cloud-talent/test/gapic_company_service_v4.ts index 168f940f703b..aea54f27de00 100644 --- a/packages/google-cloud-talent/test/gapic_company_service_v4.ts +++ b/packages/google-cloud-talent/test/gapic_company_service_v4.ts @@ -19,1057 +19,1307 @@ 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 companyserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v4.CompanyServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new companyserviceModule.v4.CompanyServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new companyserviceModule.v4.CompanyServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new companyserviceModule.v4.CompanyServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new companyserviceModule.v4.CompanyServiceClient(); + 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 = companyserviceModule.v4.CompanyServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.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 = + companyserviceModule.v4.CompanyServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = companyserviceModule.v4.CompanyServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new companyserviceModule.v4.CompanyServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + companyserviceModule.v4.CompanyServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4.CompanyServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new companyserviceModule.v4.CompanyServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); + 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 companyserviceModule.v4.CompanyServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4.CompanyServiceClient({ + 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 companyserviceModule.v4.CompanyServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - if (saved) { - process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; - } else { - delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; - } - }); + it('has port', () => { + const port = companyserviceModule.v4.CompanyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - 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 companyserviceModule.v4.CompanyServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4.CompanyServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + it('should create a client with no option', () => { + const client = new companyserviceModule.v4.CompanyServiceClient(); + assert(client); + }); - it('has port', () => { - const port = companyserviceModule.v4.CompanyServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('should create a client with gRPC fallback', () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + fallback: true, + }); + assert(client); + }); - it('should create a client with no option', () => { - const client = new companyserviceModule.v4.CompanyServiceClient(); - assert(client); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.companyServiceStub, undefined); + await client.initialize(); + assert(client.companyServiceStub); + }); - it('should create a client with gRPC fallback', () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - fallback: true, - }); - assert(client); + it('has close method for the initialized client', (done) => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.companyServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.companyServiceStub, undefined); - await client.initialize(); - assert(client.companyServiceStub); + it('has close method for the non-initialized client', (done) => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.companyServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has close method for the initialized client', done => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.companyServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new companyserviceModule.v4.CompanyServiceClient({ + 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 companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.companyServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new companyserviceModule.v4.CompanyServiceClient({ + 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 companyserviceModule.v4.CompanyServiceClient({ - 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('createCompany', () => { + it('invokes createCompany without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.createCompany = stubSimpleCall(expectedResponse); + const [response] = await client.createCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany 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 companyserviceModule.v4.CompanyServiceClient({ - 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 createCompany without error using callback', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.createCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createCompany', () => { - it('invokes createCompany without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.createCompany = stubSimpleCall(expectedResponse); - const [response] = await client.createCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCompany with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCompany without error using callback', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.createCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCompany with closed client', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCompany(request), expectedError); + }); + }); - it('invokes createCompany with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('getCompany', () => { + it('invokes getCompany without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.getCompany = stubSimpleCall(expectedResponse); + const [response] = await client.getCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createCompany with closed client', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCompany(request), expectedError); - }); + it('invokes getCompany without error using callback', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.getCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCompany', () => { - it('invokes getCompany without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.getCompany = stubSimpleCall(expectedResponse); - const [response] = await client.getCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCompany with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCompany without error using callback', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.getCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCompany with closed client', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCompany(request), expectedError); + }); + }); - it('invokes getCompany with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('updateCompany', () => { + it('invokes updateCompany without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.updateCompany = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCompany with closed client', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCompany(request), expectedError); - }); + it('invokes updateCompany without error using callback', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Company(), + ); + client.innerApiCalls.updateCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCompany', () => { - it('invokes updateCompany without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.updateCompany = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCompany with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCompany without error using callback', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Company() - ); - client.innerApiCalls.updateCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCompany with closed client', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCompany(request), expectedError); + }); + }); - it('invokes updateCompany with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('deleteCompany', () => { + it('invokes deleteCompany without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCompany = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCompany with closed client', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCompany(request), expectedError); - }); + it('invokes deleteCompany without error using callback', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCompany( + 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.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCompany', () => { - it('invokes deleteCompany without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCompany = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCompany with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCompany without error using callback', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCompany( - 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.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCompany with closed client', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteCompany(request), expectedError); + }); + }); - it('invokes deleteCompany with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + describe('listCompanies', () => { + it('invokes listCompanies without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + ]; + client.innerApiCalls.listCompanies = stubSimpleCall(expectedResponse); + const [response] = await client.listCompanies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCompany with closed client', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteCompany(request), expectedError); - }); + it('invokes listCompanies without error using callback', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + ]; + client.innerApiCalls.listCompanies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCompanies( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ICompany[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCompanies', () => { - it('invokes listCompanies without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - ]; - client.innerApiCalls.listCompanies = stubSimpleCall(expectedResponse); - const [response] = await client.listCompanies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCompanies with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCompanies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCompanies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCompanies without error using callback', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - ]; - client.innerApiCalls.listCompanies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCompanies( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ICompany[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCompaniesStream without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + ]; + client.descriptors.page.listCompanies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCompaniesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Company[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Company) => { + responses.push(response); }); - - it('invokes listCompanies with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCompanies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCompanies(request), expectedError); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCompaniesStream without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - ]; - client.descriptors.page.listCompanies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCompaniesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Company[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Company) => { - 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.listCompanies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCompanies, request)); - assert( - (client.descriptors.page.listCompanies.createStream 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.listCompanies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCompanies, request), + ); + assert( + (client.descriptors.page.listCompanies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCompaniesStream with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCompanies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCompaniesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Company[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Company) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCompanies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCompanies, request)); - assert( - (client.descriptors.page.listCompanies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCompaniesStream with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCompanies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCompaniesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Company[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Company) => { + responses.push(response); }); - - it('uses async iteration with listCompanies without error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4.Company()), - ]; - client.descriptors.page.listCompanies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4.ICompany[] = []; - const iterable = client.listCompaniesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listCompanies with error', async () => { - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCompanies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCompaniesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4.ICompany[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCompanies.asyncIterate 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.listCompanies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCompanies, request), + ); + assert( + (client.descriptors.page.listCompanies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { + it('uses async iteration with listCompanies without error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4.Company()), + ]; + client.descriptors.page.listCompanies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4.ICompany[] = []; + const iterable = client.listCompaniesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCompanies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCompanies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - describe('company', async () => { - const fakePath = "/rendered/path/company"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.companyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.companyPathTemplate.match = - sinon.stub().returns(expectedParameters); + it('uses async iteration with listCompanies with error', async () => { + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCompanies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCompaniesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4.ICompany[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCompanies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCompanies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); - it('companyPath', () => { - const result = client.companyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.companyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('Path templates', () => { + describe('company', async () => { + const fakePath = '/rendered/path/company'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.companyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.companyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('matchProjectFromCompanyName', () => { - const result = client.matchProjectFromCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('companyPath', () => { + const result = client.companyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.companyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchTenantFromCompanyName', () => { - const result = client.matchTenantFromCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromCompanyName', () => { + const result = client.matchProjectFromCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchCompanyFromCompanyName', () => { - const result = client.matchCompanyFromCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchTenantFromCompanyName', () => { + const result = client.matchTenantFromCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); + it('matchCompanyFromCompanyName', () => { + const result = client.matchCompanyFromCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('jobPath', () => { - const result = client.jobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchTenantFromJobName', () => { - const result = client.matchTenantFromJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchTenantFromJobName', () => { + const result = client.matchTenantFromJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new companyserviceModule.v4.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new companyserviceModule.v4.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_company_service_v4beta1.ts b/packages/google-cloud-talent/test/gapic_company_service_v4beta1.ts index 76ade0049031..dcab7e9c3677 100644 --- a/packages/google-cloud-talent/test/gapic_company_service_v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic_company_service_v4beta1.ts @@ -19,1163 +19,1470 @@ 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 companyserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v4beta1.CompanyServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient(); - 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 = companyserviceModule.v4beta1.CompanyServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = companyserviceModule.v4beta1.CompanyServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('has universeDomain', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.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 companyserviceModule.v4beta1.CompanyServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4beta1.CompanyServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4beta1.CompanyServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + companyserviceModule.v4beta1.CompanyServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + companyserviceModule.v4beta1.CompanyServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('has port', () => { - const port = companyserviceModule.v4beta1.CompanyServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('should create a client with no option', () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient(); - 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 companyserviceModule.v4beta1.CompanyServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 companyserviceModule.v4beta1.CompanyServiceClient({ - 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 companyserviceModule.v4beta1.CompanyServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.companyServiceStub, undefined); - await client.initialize(); - assert(client.companyServiceStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new companyserviceModule.v4beta1.CompanyServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.companyServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = companyserviceModule.v4beta1.CompanyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.companyServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - 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 companyserviceModule.v4beta1.CompanyServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - 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 companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.companyServiceStub, undefined); + await client.initialize(); + assert(client.companyServiceStub); }); - describe('createCompany', () => { - it('invokes createCompany without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.createCompany = stubSimpleCall(expectedResponse); - const [response] = await client.createCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany 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 companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.companyServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createCompany without error using callback', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.createCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany 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 companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.companyServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createCompany with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.createCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createCompany 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 companyserviceModule.v4beta1.CompanyServiceClient({ + 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 createCompany with closed client', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateCompanyRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createCompany(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + 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('createCompany', () => { + it('invokes createCompany without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.createCompany = stubSimpleCall(expectedResponse); + const [response] = await client.createCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getCompany', () => { - it('invokes getCompany without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.getCompany = stubSimpleCall(expectedResponse); - const [response] = await client.getCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCompany without error using callback', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.createCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCompany without error using callback', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.getCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCompany with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCompany with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createCompany with closed client', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateCompanyRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createCompany(request), expectedError); + }); + }); + + describe('getCompany', () => { + it('invokes getCompany without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.getCompany = stubSimpleCall(expectedResponse); + const [response] = await client.getCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getCompany with closed client', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getCompany(request), expectedError); - }); + it('invokes getCompany without error using callback', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.getCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateCompany', () => { - it('invokes updateCompany without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.updateCompany = stubSimpleCall(expectedResponse); - const [response] = await client.updateCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCompany with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCompany without error using callback', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Company() - ); - client.innerApiCalls.updateCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCompany( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ICompany|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getCompany with closed client', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getCompany(request), expectedError); + }); + }); + + describe('updateCompany', () => { + it('invokes updateCompany without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.updateCompany = stubSimpleCall(expectedResponse); + const [response] = await client.updateCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCompany with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCompany without error using callback', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Company(), + ); + client.innerApiCalls.updateCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCompany( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ICompany | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateCompany with closed client', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest() - ); - request.company ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateCompanyRequest', ['company', 'name']); - request.company.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateCompany(request), expectedError); - }); + it('invokes updateCompany with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedHeaderRequestParams = `company.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteCompany', () => { - it('invokes deleteCompany without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCompany = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCompany(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateCompany with closed client', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateCompanyRequest(), + ); + request.company ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateCompanyRequest', + ['company', 'name'], + ); + request.company.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateCompany(request), expectedError); + }); + }); + + describe('deleteCompany', () => { + it('invokes deleteCompany without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCompany = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCompany(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCompany without error using callback', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteCompany = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCompany( - 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.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCompany without error using callback', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteCompany = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCompany( + 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.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCompany with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCompany = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCompany(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteCompany as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteCompany with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCompany = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteCompany(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteCompany as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteCompany with closed client', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteCompanyRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteCompany(request), expectedError); - }); + it('invokes deleteCompany with closed client', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteCompanyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteCompanyRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteCompany(request), expectedError); + }); + }); + + describe('listCompanies', () => { + it('invokes listCompanies without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + ]; + client.innerApiCalls.listCompanies = stubSimpleCall(expectedResponse); + const [response] = await client.listCompanies(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listCompanies', () => { - it('invokes listCompanies without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - ]; - client.innerApiCalls.listCompanies = stubSimpleCall(expectedResponse); - const [response] = await client.listCompanies(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCompanies without error using callback', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + ]; + client.innerApiCalls.listCompanies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listCompanies( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ICompany[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCompanies without error using callback', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - ]; - client.innerApiCalls.listCompanies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listCompanies( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ICompany[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listCompanies with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listCompanies = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listCompanies(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listCompanies as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listCompanies with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listCompanies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listCompanies(request), expectedError); - const actualRequest = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listCompanies as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listCompaniesStream without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + ]; + client.descriptors.page.listCompanies.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listCompaniesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Company[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Company) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listCompaniesStream without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - ]; - client.descriptors.page.listCompanies.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listCompaniesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Company[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Company) => { - 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.listCompanies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCompanies, request)); - assert( - (client.descriptors.page.listCompanies.createStream 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.listCompanies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCompanies, request), + ); + assert( + (client.descriptors.page.listCompanies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listCompaniesStream with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCompanies.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listCompaniesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Company[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Company) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listCompanies.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listCompanies, request)); - assert( - (client.descriptors.page.listCompanies.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listCompaniesStream with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCompanies.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listCompaniesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Company[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Company) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listCompanies without error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), - ]; - client.descriptors.page.listCompanies.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4beta1.ICompany[] = []; - const iterable = client.listCompaniesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCompanies.asyncIterate 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.listCompanies.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listCompanies, request), + ); + assert( + (client.descriptors.page.listCompanies.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listCompanies with error', async () => { - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListCompaniesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListCompaniesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listCompanies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listCompaniesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4beta1.ICompany[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listCompanies.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listCompanies without error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Company()), + ]; + client.descriptors.page.listCompanies.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4beta1.ICompany[] = []; + const iterable = client.listCompaniesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listCompanies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCompanies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - 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('uses async iteration with listCompanies with error', async () => { + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListCompaniesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListCompaniesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listCompanies.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCompaniesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4beta1.ICompany[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listCompanies.asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + assert( + (client.descriptors.page.listCompanies.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + 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('projectCompany', async () => { - const fakePath = "/rendered/path/projectCompany"; - const expectedParameters = { - project: "projectValue", - company: "companyValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCompanyPath', () => { - const result = client.projectCompanyPath("projectValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCompanyName', () => { - const result = client.matchProjectFromProjectCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectCompanyName', () => { - const result = client.matchCompanyFromProjectCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCompany', async () => { + const fakePath = '/rendered/path/projectCompany'; + const expectedParameters = { + project: 'projectValue', + company: 'companyValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCompanyPath', () => { + const result = client.projectCompanyPath( + 'projectValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCompanyName', () => { + const result = client.matchProjectFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectCompanyName', () => { + const result = client.matchCompanyFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectJob', async () => { - const fakePath = "/rendered/path/projectJob"; - const expectedParameters = { - project: "projectValue", - job: "jobValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectJobPath', () => { - const result = client.projectJobPath("projectValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectJobName', () => { - const result = client.matchProjectFromProjectJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectJobName', () => { - const result = client.matchJobFromProjectJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectJob', async () => { + const fakePath = '/rendered/path/projectJob'; + const expectedParameters = { + project: 'projectValue', + job: 'jobValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectJobPath', () => { + const result = client.projectJobPath('projectValue', 'jobValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectJobName', () => { + const result = client.matchProjectFromProjectJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectJobName', () => { + const result = client.matchJobFromProjectJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantCompany', async () => { - const fakePath = "/rendered/path/projectTenantCompany"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantCompanyPath', () => { - const result = client.projectTenantCompanyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantCompanyName', () => { - const result = client.matchProjectFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantCompanyName', () => { - const result = client.matchTenantFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectTenantCompanyName', () => { - const result = client.matchCompanyFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantCompany', async () => { + const fakePath = '/rendered/path/projectTenantCompany'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantCompanyPath', () => { + const result = client.projectTenantCompanyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantCompanyName', () => { + const result = + client.matchProjectFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantCompanyName', () => { + const result = client.matchTenantFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectTenantCompanyName', () => { + const result = + client.matchCompanyFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantJob', async () => { - const fakePath = "/rendered/path/projectTenantJob"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantJobPath', () => { - const result = client.projectTenantJobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantJobName', () => { - const result = client.matchProjectFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantJobName', () => { - const result = client.matchTenantFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectTenantJobName', () => { - const result = client.matchJobFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantJob', async () => { + const fakePath = '/rendered/path/projectTenantJob'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantJobPath', () => { + const result = client.projectTenantJobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantJobPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantJobName', () => { + const result = client.matchProjectFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantJobName', () => { + const result = client.matchTenantFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectTenantJobName', () => { + const result = client.matchJobFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new companyserviceModule.v4beta1.CompanyServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new companyserviceModule.v4beta1.CompanyServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_completion_v4.ts b/packages/google-cloud-talent/test/gapic_completion_v4.ts index 400dc7c25301..cf2bc4d49fe6 100644 --- a/packages/google-cloud-talent/test/gapic_completion_v4.ts +++ b/packages/google-cloud-talent/test/gapic_completion_v4.ts @@ -19,437 +19,547 @@ 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 completionModule from '../src'; -import {protobuf} from 'google-gax'; +import { protobuf } 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); } describe('v4.CompletionClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new completionModule.v4.CompletionClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new completionModule.v4.CompletionClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new completionModule.v4.CompletionClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new completionModule.v4.CompletionClient(); + 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 = completionModule.v4.CompletionClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = completionModule.v4.CompletionClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new completionModule.v4.CompletionClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 = completionModule.v4.CompletionClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = completionModule.v4.CompletionClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new completionModule.v4.CompletionClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new completionModule.v4.CompletionClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new completionModule.v4.CompletionClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 completionModule.v4.CompletionClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 completionModule.v4.CompletionClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 completionModule.v4.CompletionClient({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 completionModule.v4.CompletionClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = completionModule.v4.CompletionClient.port; - assert(port); - assert(typeof port === 'number'); + 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 completionModule.v4.CompletionClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.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 no option', () => { - const client = new completionModule.v4.CompletionClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new completionModule.v4.CompletionClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new completionModule.v4.CompletionClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = completionModule.v4.CompletionClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionStub, undefined); - await client.initialize(); - assert(client.completionStub); - }); + it('should create a client with no option', () => { + const client = new completionModule.v4.CompletionClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.completionStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new completionModule.v4.CompletionClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.completionStub, undefined); + await client.initialize(); + assert(client.completionStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionModule.v4.CompletionClient({ - 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 completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.completionStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionModule.v4.CompletionClient({ - 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 completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.completionStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CompleteQueryRequest', ['tenant']); - request.tenant = defaultValue1; - const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery 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 completionModule.v4.CompletionClient({ + 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 completeQuery without error using callback', async () => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CompleteQueryRequest', ['tenant']); - request.tenant = defaultValue1; - const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery 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 completionModule.v4.CompletionClient({ + 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('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CompleteQueryRequest', + ['tenant'], + ); + request.tenant = defaultValue1; + const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryResponse(), + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes completeQuery with error', async () => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CompleteQueryRequest', ['tenant']); - request.tenant = defaultValue1; - const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes completeQuery without error using callback', async () => { + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CompleteQueryRequest', + ['tenant'], + ); + request.tenant = defaultValue1; + const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryResponse(), + ); + client.innerApiCalls.completeQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ICompleteQueryResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes completeQuery with closed client', async () => { - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CompleteQueryRequest', ['tenant']); - request.tenant = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.completeQuery(request), expectedError); - }); + it('invokes completeQuery with error', async () => { + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CompleteQueryRequest', + ['tenant'], + ); + request.tenant = defaultValue1; + const expectedHeaderRequestParams = `tenant=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('company', async () => { - const fakePath = "/rendered/path/company"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.companyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.companyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('companyPath', () => { - const result = client.companyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.companyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompanyName', () => { - const result = client.matchProjectFromCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromCompanyName', () => { - const result = client.matchTenantFromCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromCompanyName', () => { - const result = client.matchCompanyFromCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes completeQuery with closed client', async () => { + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CompleteQueryRequest', + ['tenant'], + ); + request.tenant = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('Path templates', () => { + describe('company', async () => { + const fakePath = '/rendered/path/company'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.companyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.companyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('companyPath', () => { + const result = client.companyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.companyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCompanyName', () => { + const result = client.matchProjectFromCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromCompanyName', () => { + const result = client.matchTenantFromCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromCompanyName', () => { + const result = client.matchCompanyFromCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromJobName', () => { - const result = client.matchTenantFromJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromJobName', () => { + const result = client.matchTenantFromJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new completionModule.v4.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new completionModule.v4.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_completion_v4beta1.ts b/packages/google-cloud-talent/test/gapic_completion_v4beta1.ts index 2602edd4f0a1..34897e4fc7ae 100644 --- a/packages/google-cloud-talent/test/gapic_completion_v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic_completion_v4beta1.ts @@ -19,543 +19,705 @@ 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 completionModule from '../src'; -import {protobuf} from 'google-gax'; +import { protobuf } 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); } describe('v4beta1.CompletionClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new completionModule.v4beta1.CompletionClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new completionModule.v4beta1.CompletionClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new completionModule.v4beta1.CompletionClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new completionModule.v4beta1.CompletionClient(); + 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 = completionModule.v4beta1.CompletionClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = completionModule.v4beta1.CompletionClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new completionModule.v4beta1.CompletionClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 = + completionModule.v4beta1.CompletionClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + completionModule.v4beta1.CompletionClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new completionModule.v4beta1.CompletionClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new completionModule.v4beta1.CompletionClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new completionModule.v4beta1.CompletionClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 completionModule.v4beta1.CompletionClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 completionModule.v4beta1.CompletionClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 completionModule.v4beta1.CompletionClient({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 completionModule.v4beta1.CompletionClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = completionModule.v4beta1.CompletionClient.port; - assert(port); - assert(typeof port === 'number'); + 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 completionModule.v4beta1.CompletionClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.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 no option', () => { - const client = new completionModule.v4beta1.CompletionClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new completionModule.v4beta1.CompletionClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new completionModule.v4beta1.CompletionClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = completionModule.v4beta1.CompletionClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionStub, undefined); - await client.initialize(); - assert(client.completionStub); - }); + it('should create a client with no option', () => { + const client = new completionModule.v4beta1.CompletionClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.completionStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new completionModule.v4beta1.CompletionClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.completionStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.completionStub, undefined); + await client.initialize(); + assert(client.completionStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionModule.v4beta1.CompletionClient({ - 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 completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.completionStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new completionModule.v4beta1.CompletionClient({ - 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 completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.completionStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('completeQuery', () => { - it('invokes completeQuery without error', async () => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CompleteQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); - const [response] = await client.completeQuery(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery 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 completionModule.v4beta1.CompletionClient({ + 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 completeQuery without error using callback', async () => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CompleteQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryResponse() - ); - client.innerApiCalls.completeQuery = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.completeQuery( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ICompleteQueryResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery 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 completionModule.v4beta1.CompletionClient({ + 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('completeQuery', () => { + it('invokes completeQuery without error', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CompleteQueryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryResponse(), + ); + client.innerApiCalls.completeQuery = stubSimpleCall(expectedResponse); + const [response] = await client.completeQuery(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes completeQuery with error', async () => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CompleteQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.completeQuery = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.completeQuery(request), expectedError); - const actualRequest = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.completeQuery as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes completeQuery without error using callback', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CompleteQueryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryResponse(), + ); + client.innerApiCalls.completeQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.completeQuery( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ICompleteQueryResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes completeQuery with closed client', async () => { - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CompleteQueryRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CompleteQueryRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.completeQuery(request), expectedError); - }); + it('invokes completeQuery with error', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CompleteQueryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.completeQuery = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.completeQuery(request), expectedError); + const actualRequest = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.completeQuery as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - 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('invokes completeQuery with closed client', async () => { + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CompleteQueryRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CompleteQueryRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.completeQuery(request), expectedError); + }); + }); + + describe('Path templates', () => { + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + 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('projectCompany', async () => { - const fakePath = "/rendered/path/projectCompany"; - const expectedParameters = { - project: "projectValue", - company: "companyValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCompanyPath', () => { - const result = client.projectCompanyPath("projectValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCompanyName', () => { - const result = client.matchProjectFromProjectCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectCompanyName', () => { - const result = client.matchCompanyFromProjectCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCompany', async () => { + const fakePath = '/rendered/path/projectCompany'; + const expectedParameters = { + project: 'projectValue', + company: 'companyValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCompanyPath', () => { + const result = client.projectCompanyPath( + 'projectValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCompanyName', () => { + const result = client.matchProjectFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectCompanyName', () => { + const result = client.matchCompanyFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectJob', async () => { - const fakePath = "/rendered/path/projectJob"; - const expectedParameters = { - project: "projectValue", - job: "jobValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectJobPath', () => { - const result = client.projectJobPath("projectValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectJobName', () => { - const result = client.matchProjectFromProjectJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectJobName', () => { - const result = client.matchJobFromProjectJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectJob', async () => { + const fakePath = '/rendered/path/projectJob'; + const expectedParameters = { + project: 'projectValue', + job: 'jobValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectJobPath', () => { + const result = client.projectJobPath('projectValue', 'jobValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectJobName', () => { + const result = client.matchProjectFromProjectJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectJobName', () => { + const result = client.matchJobFromProjectJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantCompany', async () => { - const fakePath = "/rendered/path/projectTenantCompany"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantCompanyPath', () => { - const result = client.projectTenantCompanyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantCompanyName', () => { - const result = client.matchProjectFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantCompanyName', () => { - const result = client.matchTenantFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectTenantCompanyName', () => { - const result = client.matchCompanyFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantCompany', async () => { + const fakePath = '/rendered/path/projectTenantCompany'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantCompanyPath', () => { + const result = client.projectTenantCompanyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantCompanyName', () => { + const result = + client.matchProjectFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantCompanyName', () => { + const result = client.matchTenantFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectTenantCompanyName', () => { + const result = + client.matchCompanyFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantJob', async () => { - const fakePath = "/rendered/path/projectTenantJob"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantJobPath', () => { - const result = client.projectTenantJobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantJobName', () => { - const result = client.matchProjectFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantJobName', () => { - const result = client.matchTenantFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectTenantJobName', () => { - const result = client.matchJobFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantJob', async () => { + const fakePath = '/rendered/path/projectTenantJob'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantJobPath', () => { + const result = client.projectTenantJobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantJobPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantJobName', () => { + const result = client.matchProjectFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantJobName', () => { + const result = client.matchTenantFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectTenantJobName', () => { + const result = client.matchJobFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new completionModule.v4beta1.CompletionClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new completionModule.v4beta1.CompletionClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_event_service_v4.ts b/packages/google-cloud-talent/test/gapic_event_service_v4.ts index 588cd87eaaf3..147f20ef00bc 100644 --- a/packages/google-cloud-talent/test/gapic_event_service_v4.ts +++ b/packages/google-cloud-talent/test/gapic_event_service_v4.ts @@ -19,437 +19,549 @@ 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 eventserviceModule from '../src'; -import {protobuf} from 'google-gax'; +import { protobuf } 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); } describe('v4.EventServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new eventserviceModule.v4.EventServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new eventserviceModule.v4.EventServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new eventserviceModule.v4.EventServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new eventserviceModule.v4.EventServiceClient(); + 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 = eventserviceModule.v4.EventServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = eventserviceModule.v4.EventServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new eventserviceModule.v4.EventServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 = + eventserviceModule.v4.EventServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + eventserviceModule.v4.EventServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new eventserviceModule.v4.EventServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new eventserviceModule.v4.EventServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new eventserviceModule.v4.EventServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4.EventServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4.EventServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4.EventServiceClient({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 eventserviceModule.v4.EventServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = eventserviceModule.v4.EventServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 eventserviceModule.v4.EventServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.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 no option', () => { - const client = new eventserviceModule.v4.EventServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new eventserviceModule.v4.EventServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new eventserviceModule.v4.EventServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = eventserviceModule.v4.EventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.eventServiceStub, undefined); - await client.initialize(); - assert(client.eventServiceStub); - }); + it('should create a client with no option', () => { + const client = new eventserviceModule.v4.EventServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.eventServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new eventserviceModule.v4.EventServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.eventServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.eventServiceStub, undefined); + await client.initialize(); + assert(client.eventServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new eventserviceModule.v4.EventServiceClient({ - 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 eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.eventServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new eventserviceModule.v4.EventServiceClient({ - 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 eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.eventServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createClientEvent', () => { - it('invokes createClientEvent without error', async () => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.ClientEvent() - ); - client.innerApiCalls.createClientEvent = stubSimpleCall(expectedResponse); - const [response] = await client.createClientEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent 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 eventserviceModule.v4.EventServiceClient({ + 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 createClientEvent without error using callback', async () => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.ClientEvent() - ); - client.innerApiCalls.createClientEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createClientEvent( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.IClientEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent 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 eventserviceModule.v4.EventServiceClient({ + 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('createClientEvent', () => { + it('invokes createClientEvent without error', async () => { + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.ClientEvent(), + ); + client.innerApiCalls.createClientEvent = stubSimpleCall(expectedResponse); + const [response] = await client.createClientEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createClientEvent with error', async () => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createClientEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createClientEvent without error using callback', async () => { + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.ClientEvent(), + ); + client.innerApiCalls.createClientEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createClientEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.IClientEvent | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createClientEvent with closed client', async () => { - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createClientEvent(request), expectedError); - }); + it('invokes createClientEvent with error', async () => { + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientEvent = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createClientEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('company', async () => { - const fakePath = "/rendered/path/company"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.companyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.companyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('companyPath', () => { - const result = client.companyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.companyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompanyName', () => { - const result = client.matchProjectFromCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromCompanyName', () => { - const result = client.matchTenantFromCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromCompanyName', () => { - const result = client.matchCompanyFromCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('invokes createClientEvent with closed client', async () => { + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createClientEvent(request), expectedError); + }); + }); + + describe('Path templates', () => { + describe('company', async () => { + const fakePath = '/rendered/path/company'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.companyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.companyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('companyPath', () => { + const result = client.companyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.companyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCompanyName', () => { + const result = client.matchProjectFromCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromCompanyName', () => { + const result = client.matchTenantFromCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromCompanyName', () => { + const result = client.matchCompanyFromCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromJobName', () => { - const result = client.matchTenantFromJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromJobName', () => { + const result = client.matchTenantFromJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new eventserviceModule.v4.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new eventserviceModule.v4.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_event_service_v4beta1.ts b/packages/google-cloud-talent/test/gapic_event_service_v4beta1.ts index 3998731cd24e..544ccac25573 100644 --- a/packages/google-cloud-talent/test/gapic_event_service_v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic_event_service_v4beta1.ts @@ -19,543 +19,705 @@ 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 eventserviceModule from '../src'; -import {protobuf} from 'google-gax'; +import { protobuf } 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); } describe('v4beta1.EventServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient(); + 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 = eventserviceModule.v4beta1.EventServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = eventserviceModule.v4beta1.EventServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 = + eventserviceModule.v4beta1.EventServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + eventserviceModule.v4beta1.EventServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4beta1.EventServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4beta1.EventServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 eventserviceModule.v4beta1.EventServiceClient({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 eventserviceModule.v4beta1.EventServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = eventserviceModule.v4beta1.EventServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 eventserviceModule.v4beta1.EventServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.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 no option', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new eventserviceModule.v4beta1.EventServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = eventserviceModule.v4beta1.EventServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.eventServiceStub, undefined); - await client.initialize(); - assert(client.eventServiceStub); - }); + it('should create a client with no option', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.eventServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.eventServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.eventServiceStub, undefined); + await client.initialize(); + assert(client.eventServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - 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 eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.eventServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - 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 eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.eventServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createClientEvent', () => { - it('invokes createClientEvent without error', async () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ClientEvent() - ); - client.innerApiCalls.createClientEvent = stubSimpleCall(expectedResponse); - const [response] = await client.createClientEvent(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent 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 eventserviceModule.v4beta1.EventServiceClient({ + 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 createClientEvent without error using callback', async () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ClientEvent() - ); - client.innerApiCalls.createClientEvent = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createClientEvent( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.IClientEvent|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent 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 eventserviceModule.v4beta1.EventServiceClient({ + 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('createClientEvent', () => { + it('invokes createClientEvent without error', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ClientEvent(), + ); + client.innerApiCalls.createClientEvent = stubSimpleCall(expectedResponse); + const [response] = await client.createClientEvent(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createClientEvent with error', async () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createClientEvent = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createClientEvent(request), expectedError); - const actualRequest = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createClientEvent as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createClientEvent without error using callback', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ClientEvent(), + ); + client.innerApiCalls.createClientEvent = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createClientEvent( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.IClientEvent | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createClientEvent with closed client', async () => { - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateClientEventRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateClientEventRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createClientEvent(request), expectedError); - }); + it('invokes createClientEvent with error', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createClientEvent = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createClientEvent(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createClientEvent as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('Path templates', () => { - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - 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('invokes createClientEvent with closed client', async () => { + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateClientEventRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateClientEventRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createClientEvent(request), expectedError); + }); + }); + + describe('Path templates', () => { + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + 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('projectCompany', async () => { - const fakePath = "/rendered/path/projectCompany"; - const expectedParameters = { - project: "projectValue", - company: "companyValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCompanyPath', () => { - const result = client.projectCompanyPath("projectValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCompanyName', () => { - const result = client.matchProjectFromProjectCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectCompanyName', () => { - const result = client.matchCompanyFromProjectCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCompany', async () => { + const fakePath = '/rendered/path/projectCompany'; + const expectedParameters = { + project: 'projectValue', + company: 'companyValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCompanyPath', () => { + const result = client.projectCompanyPath( + 'projectValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCompanyName', () => { + const result = client.matchProjectFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectCompanyName', () => { + const result = client.matchCompanyFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectJob', async () => { - const fakePath = "/rendered/path/projectJob"; - const expectedParameters = { - project: "projectValue", - job: "jobValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectJobPath', () => { - const result = client.projectJobPath("projectValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectJobName', () => { - const result = client.matchProjectFromProjectJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectJobName', () => { - const result = client.matchJobFromProjectJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectJob', async () => { + const fakePath = '/rendered/path/projectJob'; + const expectedParameters = { + project: 'projectValue', + job: 'jobValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectJobPath', () => { + const result = client.projectJobPath('projectValue', 'jobValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectJobName', () => { + const result = client.matchProjectFromProjectJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectJobName', () => { + const result = client.matchJobFromProjectJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantCompany', async () => { - const fakePath = "/rendered/path/projectTenantCompany"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantCompanyPath', () => { - const result = client.projectTenantCompanyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantCompanyName', () => { - const result = client.matchProjectFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantCompanyName', () => { - const result = client.matchTenantFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectTenantCompanyName', () => { - const result = client.matchCompanyFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantCompany', async () => { + const fakePath = '/rendered/path/projectTenantCompany'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantCompanyPath', () => { + const result = client.projectTenantCompanyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantCompanyName', () => { + const result = + client.matchProjectFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantCompanyName', () => { + const result = client.matchTenantFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectTenantCompanyName', () => { + const result = + client.matchCompanyFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantJob', async () => { - const fakePath = "/rendered/path/projectTenantJob"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantJobPath', () => { - const result = client.projectTenantJobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantJobName', () => { - const result = client.matchProjectFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantJobName', () => { - const result = client.matchTenantFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectTenantJobName', () => { - const result = client.matchJobFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantJob', async () => { + const fakePath = '/rendered/path/projectTenantJob'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantJobPath', () => { + const result = client.projectTenantJobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantJobPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantJobName', () => { + const result = client.matchProjectFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantJobName', () => { + const result = client.matchTenantFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectTenantJobName', () => { + const result = client.matchJobFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new eventserviceModule.v4beta1.EventServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new eventserviceModule.v4beta1.EventServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_job_service_v4.ts b/packages/google-cloud-talent/test/gapic_job_service_v4.ts index d5bb1f575a19..e9bbf2dc1f54 100644 --- a/packages/google-cloud-talent/test/gapic_job_service_v4.ts +++ b/packages/google-cloud-talent/test/gapic_job_service_v4.ts @@ -19,2036 +19,2524 @@ 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 jobserviceModule 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('v4.JobServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new jobserviceModule.v4.JobServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new jobserviceModule.v4.JobServiceClient(); - 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 = jobserviceModule.v4.JobServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = jobserviceModule.v4.JobServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new jobserviceModule.v4.JobServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new jobserviceModule.v4.JobServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4.JobServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4.JobServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4.JobServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = jobserviceModule.v4.JobServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new jobserviceModule.v4.JobServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new jobserviceModule.v4.JobServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobServiceStub, undefined); - await client.initialize(); - assert(client.jobServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.jobServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new jobserviceModule.v4.JobServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobserviceModule.v4.JobServiceClient({ - 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 universeDomain', () => { + const client = new jobserviceModule.v4.JobServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobserviceModule.v4.JobServiceClient({ - 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' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = jobserviceModule.v4.JobServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = jobserviceModule.v4.JobServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new jobserviceModule.v4.JobServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); }); - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob 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 jobserviceModule.v4.JobServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('invokes createJob without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob 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 jobserviceModule.v4.JobServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4.JobServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4.JobServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes createJob with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = jobserviceModule.v4.JobServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes createJob with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createJob(request), expectedError); - }); + it('should create a client with no option', () => { + const client = new jobserviceModule.v4.JobServiceClient(); + assert(client); }); - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4.JobServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getJob without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.jobServiceStub, undefined); + await client.initialize(); + assert(client.jobServiceStub); + }); - it('invokes getJob with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.jobServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getJob with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getJob(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.jobServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob 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 jobserviceModule.v4.JobServiceClient({ + 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 updateJob without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob 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 jobserviceModule.v4.JobServiceClient({ + 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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateJob with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createJob without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.createJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateJob with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateJob(request), expectedError); - }); + it('invokes createJob with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createJob with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getJob without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.getJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getJob with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteJob(request), expectedError); - }); + it('invokes getJob with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchJobs', () => { - it('invokes searchJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsResponse() - ); - client.innerApiCalls.searchJobs = stubSimpleCall(expectedResponse); - const [response] = await client.searchJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Job(), + ); + client.innerApiCalls.updateJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsResponse() - ); - client.innerApiCalls.searchJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchJobs( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ISearchJobsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.searchJobs(request), expectedError); - }); + it('invokes deleteJob without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchJobsForAlert', () => { - it('invokes searchJobsForAlert without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsResponse() - ); - client.innerApiCalls.searchJobsForAlert = stubSimpleCall(expectedResponse); - const [response] = await client.searchJobsForAlert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteJob with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsResponse() - ); - client.innerApiCalls.searchJobsForAlert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchJobsForAlert( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ISearchJobsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteJob with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('searchJobs', () => { + it('invokes searchJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobs = stubSimpleCall(expectedResponse); + const [response] = await client.searchJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchJobsForAlert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchJobsForAlert(request), expectedError); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobs without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ISearchJobsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert with closed client', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.searchJobsForAlert(request), expectedError); - }); + it('invokes searchJobs with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchJobs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchCreateJobs', () => { - it('invokes batchCreateJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchCreateJobs(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobs with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.searchJobs(request), expectedError); + }); + }); + + describe('searchJobsForAlert', () => { + it('invokes searchJobsForAlert without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobsForAlert = + stubSimpleCall(expectedResponse); + const [response] = await client.searchJobsForAlert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchCreateJobs = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateJobs( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobsForAlert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchJobsForAlert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ISearchJobsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs with call error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchCreateJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchJobsForAlert = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchJobsForAlert(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs with LRO error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchCreateJobs(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert with closed client', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.searchJobsForAlert(request), expectedError); + }); + }); + + describe('batchCreateJobs', () => { + it('invokes batchCreateJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchCreateJobs = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchCreateJobs(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchCreateJobsProgress without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchCreateJobsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchCreateJobs without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchCreateJobs = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateJobs( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.talent.v4.IBatchCreateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchCreateJobsProgress with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchCreateJobsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes batchCreateJobs with call error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateJobs = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchCreateJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchUpdateJobs', () => { - it('invokes batchUpdateJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchUpdateJobs(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchCreateJobs with LRO error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateJobs = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchCreateJobs(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateJobs without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchUpdateJobs( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchCreateJobsProgress without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchCreateJobsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes batchUpdateJobs with call error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchUpdateJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchCreateJobsProgress with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchCreateJobsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('batchUpdateJobs', () => { + it('invokes batchUpdateJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchUpdateJobs = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchUpdateJobs(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateJobs with LRO error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchUpdateJobs(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchUpdateJobs without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchUpdateJobs = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchUpdateJobs( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.talent.v4.IBatchUpdateJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchUpdateJobsProgress without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchUpdateJobsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchUpdateJobs with call error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchUpdateJobs = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchUpdateJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchUpdateJobsProgress with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchUpdateJobsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes batchUpdateJobs with LRO error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchUpdateJobs = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchUpdateJobs(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchDeleteJobs', () => { - it('invokes batchDeleteJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchDeleteJobs = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchDeleteJobs(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchUpdateJobsProgress without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchUpdateJobsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes batchDeleteJobs without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchDeleteJobs = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchDeleteJobs( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchUpdateJobsProgress with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchUpdateJobsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('batchDeleteJobs', () => { + it('invokes batchDeleteJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchDeleteJobs = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchDeleteJobs(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteJobs with call error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchDeleteJobs = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchDeleteJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteJobs without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchDeleteJobs = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchDeleteJobs( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.talent.v4.IBatchDeleteJobsResponse, + protos.google.cloud.talent.v4.IBatchOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteJobs with LRO error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchDeleteJobs = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchDeleteJobs(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteJobs with call error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchDeleteJobs = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchDeleteJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchDeleteJobsProgress without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchDeleteJobsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchDeleteJobs with LRO error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchDeleteJobs = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchDeleteJobs(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchDeleteJobsProgress with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchDeleteJobsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkBatchDeleteJobsProgress without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchDeleteJobsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchDeleteJobsProgress with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchDeleteJobsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobs without error using callback', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listJobs without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + ]; + client.innerApiCalls.listJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.IJob[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobs with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listJobs with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobsStream without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Job[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listJobsStream without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + ]; + client.descriptors.page.listJobs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Job[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listJobsStream with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Job[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listJobsStream with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Job[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Job) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listJobs without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listJobs without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listJobs with error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listJobs with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.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 jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + 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), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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)); - }); + it('invokes getOperation without error using callback', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + 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)); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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 getOperation with error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + 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('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ - 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('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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 jobserviceModule.v4.JobServiceClient({ + 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('company', async () => { + const fakePath = '/rendered/path/company'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.companyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.companyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('companyPath', () => { + const result = client.companyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.companyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCompanyName', () => { + const result = client.matchProjectFromCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromCompanyName', () => { + const result = client.matchTenantFromCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromCompanyName', () => { + const result = client.matchCompanyFromCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); - describe('Path templates', () => { - - describe('company', async () => { - const fakePath = "/rendered/path/company"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.companyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.companyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('companyPath', () => { - const result = client.companyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.companyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompanyName', () => { - const result = client.matchProjectFromCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromCompanyName', () => { - const result = client.matchTenantFromCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromCompanyName', () => { - const result = client.matchCompanyFromCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromJobName', () => { - const result = client.matchTenantFromJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromJobName', () => { + const result = client.matchTenantFromJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new jobserviceModule.v4.JobServiceClient({ - 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 jobserviceModule.v4.JobServiceClient({ + 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('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new jobserviceModule.v4.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new jobserviceModule.v4.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_job_service_v4beta1.ts b/packages/google-cloud-talent/test/gapic_job_service_v4beta1.ts index e4218f7ef719..f418bc6b9b0f 100644 --- a/packages/google-cloud-talent/test/gapic_job_service_v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic_job_service_v4beta1.ts @@ -19,2066 +19,2588 @@ 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 jobserviceModule 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('v4beta1.JobServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient(); - 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 = jobserviceModule.v4beta1.JobServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = jobserviceModule.v4beta1.JobServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4beta1.JobServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4beta1.JobServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4beta1.JobServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = jobserviceModule.v4beta1.JobServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobServiceStub, undefined); - await client.initialize(); - assert(client.jobServiceStub); - }); - - it('has close method for the initialized client', done => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.jobServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.jobServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new jobserviceModule.v4beta1.JobServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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 universeDomain', () => { + const client = new jobserviceModule.v4beta1.JobServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + jobserviceModule.v4beta1.JobServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + jobserviceModule.v4beta1.JobServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); }); - describe('createJob', () => { - it('invokes createJob without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); - const [response] = await client.createJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob 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 jobserviceModule.v4beta1.JobServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('invokes createJob without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.createJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob 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 jobserviceModule.v4beta1.JobServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4beta1.JobServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 jobserviceModule.v4beta1.JobServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes createJob with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createJob(request), expectedError); - const actualRequest = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = jobserviceModule.v4beta1.JobServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes createJob with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateJobRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createJob(request), expectedError); - }); + it('should create a client with no option', () => { + const client = new jobserviceModule.v4beta1.JobServiceClient(); + assert(client); }); - describe('getJob', () => { - it('invokes getJob without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); - const [response] = await client.getJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4beta1.JobServiceClient({ + fallback: true, + }); + assert(client); + }); - it('invokes getJob without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.getJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.jobServiceStub, undefined); + await client.initialize(); + assert(client.jobServiceStub); + }); - it('invokes getJob with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getJob(request), expectedError); - const actualRequest = (client.innerApiCalls.getJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getJob 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 jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.jobServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes getJob with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getJob(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.jobServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('updateJob', () => { - it('invokes updateJob without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); - const [response] = await client.updateJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 updateJob without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Job() - ); - client.innerApiCalls.updateJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateJob( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.IJob|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob 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 jobserviceModule.v4beta1.JobServiceClient({ + 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('createJob', () => { + it('invokes createJob without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.createJob = stubSimpleCall(expectedResponse); + const [response] = await client.createJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateJob with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateJob(request), expectedError); - const actualRequest = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createJob without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.createJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateJob with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateJobRequest() - ); - request.job ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateJobRequest', ['job', 'name']); - request.job.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateJob(request), expectedError); - }); + it('invokes createJob with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteJob', () => { - it('invokes deleteJob without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); - const [response] = await client.deleteJob(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createJob with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateJobRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createJob(request), expectedError); + }); + }); + + describe('getJob', () => { + it('invokes getJob without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.getJob = stubSimpleCall(expectedResponse); + const [response] = await client.getJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteJob = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteJob( - 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.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getJob without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.getJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteJob(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteJob as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getJob with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getJob(request), expectedError); + const actualRequest = (client.innerApiCalls.getJob as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteJob with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteJobRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteJobRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteJob(request), expectedError); - }); + it('invokes getJob with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getJob(request), expectedError); + }); + }); + + describe('updateJob', () => { + it('invokes updateJob without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.updateJob = stubSimpleCall(expectedResponse); + const [response] = await client.updateJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchDeleteJobs', () => { - it('invokes batchDeleteJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.batchDeleteJobs = stubSimpleCall(expectedResponse); - const [response] = await client.batchDeleteJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Job(), + ); + client.innerApiCalls.updateJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateJob( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.IJob | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteJobs without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.batchDeleteJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchDeleteJobs( - 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.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedHeaderRequestParams = `job.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteJobs with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchDeleteJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.batchDeleteJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchDeleteJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateJob with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateJobRequest(), + ); + request.job ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateJobRequest', + ['job', 'name'], + ); + request.job.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateJob(request), expectedError); + }); + }); + + describe('deleteJob', () => { + it('invokes deleteJob without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = stubSimpleCall(expectedResponse); + const [response] = await client.deleteJob(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchDeleteJobs with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.batchDeleteJobs(request), expectedError); - }); + it('invokes deleteJob without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteJob = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteJob( + 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.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchJobs', () => { - it('invokes searchJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsResponse() - ); - client.innerApiCalls.searchJobs = stubSimpleCall(expectedResponse); - const [response] = await client.searchJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteJob with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteJob = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteJob(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteJob as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsResponse() - ); - client.innerApiCalls.searchJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchJobs( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ISearchJobsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteJob with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteJobRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteJobRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteJob(request), expectedError); + }); + }); + + describe('batchDeleteJobs', () => { + it('invokes batchDeleteJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.batchDeleteJobs = stubSimpleCall(expectedResponse); + const [response] = await client.batchDeleteJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteJobs without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.batchDeleteJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchDeleteJobs( + 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.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobs with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.searchJobs(request), expectedError); - }); + it('invokes batchDeleteJobs with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchDeleteJobs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchDeleteJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchDeleteJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('searchJobsForAlert', () => { - it('invokes searchJobsForAlert without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsResponse() - ); - client.innerApiCalls.searchJobsForAlert = stubSimpleCall(expectedResponse); - const [response] = await client.searchJobsForAlert(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchDeleteJobs with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchDeleteJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchDeleteJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.batchDeleteJobs(request), expectedError); + }); + }); + + describe('searchJobs', () => { + it('invokes searchJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobs = stubSimpleCall(expectedResponse); + const [response] = await client.searchJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsResponse() - ); - client.innerApiCalls.searchJobsForAlert = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.searchJobsForAlert( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ISearchJobsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobs without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ISearchJobsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.searchJobsForAlert = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.searchJobsForAlert(request), expectedError); - const actualRequest = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.searchJobsForAlert as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobs with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchJobs = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes searchJobsForAlert with closed client', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.SearchJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.SearchJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.searchJobsForAlert(request), expectedError); - }); + it('invokes searchJobs with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.searchJobs(request), expectedError); + }); + }); + + describe('searchJobsForAlert', () => { + it('invokes searchJobsForAlert without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobsForAlert = + stubSimpleCall(expectedResponse); + const [response] = await client.searchJobsForAlert(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchCreateJobs', () => { - it('invokes batchCreateJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchCreateJobs(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsResponse(), + ); + client.innerApiCalls.searchJobsForAlert = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.searchJobsForAlert( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ISearchJobsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchCreateJobs = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchCreateJobs( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.searchJobsForAlert = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.searchJobsForAlert(request), expectedError); + const actualRequest = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.searchJobsForAlert as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs with call error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchCreateJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes searchJobsForAlert with closed client', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.SearchJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.SearchJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.searchJobsForAlert(request), expectedError); + }); + }); + + describe('batchCreateJobs', () => { + it('invokes batchCreateJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchCreateJobs = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchCreateJobs(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchCreateJobs with LRO error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchCreateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchCreateJobs = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchCreateJobs(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchCreateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchCreateJobs without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchCreateJobs = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchCreateJobs( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchCreateJobsProgress without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchCreateJobsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchCreateJobs with call error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateJobs = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchCreateJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchCreateJobsProgress with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchCreateJobsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes batchCreateJobs with LRO error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchCreateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchCreateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchCreateJobs = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchCreateJobs(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchCreateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('batchUpdateJobs', () => { - it('invokes batchUpdateJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(expectedResponse); - const [operation] = await client.batchUpdateJobs(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchCreateJobsProgress without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchCreateJobsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes batchUpdateJobs without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.longrunning.Operation() - ); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.batchUpdateJobs( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchCreateJobsProgress with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchCreateJobsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('batchUpdateJobs', () => { + it('invokes batchUpdateJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchUpdateJobs = + stubLongRunningCall(expectedResponse); + const [operation] = await client.batchUpdateJobs(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateJobs with call error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.batchUpdateJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchUpdateJobs without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.batchUpdateJobs = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.batchUpdateJobs( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.cloud.talent.v4beta1.IJobOperationResult, + protos.google.cloud.talent.v4beta1.IBatchOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes batchUpdateJobs with LRO error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.batchUpdateJobs = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.batchUpdateJobs(request); - await assert.rejects(operation.promise(), expectedError); - const actualRequest = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.batchUpdateJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes batchUpdateJobs with call error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchUpdateJobs = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.batchUpdateJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchUpdateJobsProgress without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkBatchUpdateJobsProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes batchUpdateJobs with LRO error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.BatchUpdateJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.BatchUpdateJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.batchUpdateJobs = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.batchUpdateJobs(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.batchUpdateJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes checkBatchUpdateJobsProgress with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkBatchUpdateJobsProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkBatchUpdateJobsProgress without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation(), + ); + expectedResponse.name = 'test'; + expectedResponse.response = { type_url: 'url', value: Buffer.from('') }; + expectedResponse.metadata = { type_url: 'url', value: Buffer.from('') }; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkBatchUpdateJobsProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('listJobs', () => { - it('invokes listJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); - const [response] = await client.listJobs(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes checkBatchUpdateJobsProgress with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkBatchUpdateJobsProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listJobs', () => { + it('invokes listJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + ]; + client.innerApiCalls.listJobs = stubSimpleCall(expectedResponse); + const [response] = await client.listJobs(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobs without error using callback', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - ]; - client.innerApiCalls.listJobs = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listJobs( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.IJob[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listJobs without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + ]; + client.innerApiCalls.listJobs = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listJobs( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.IJob[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobs with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listJobs(request), expectedError); - const actualRequest = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listJobs as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listJobs with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listJobs = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listJobs(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listJobs as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listJobsStream without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - ]; - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Job) => { - 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.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listJobsStream without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + ]; + client.descriptors.page.listJobs.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Job[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Job) => { + 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.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listJobsStream with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listJobsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Job[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Job) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listJobs, request)); - assert( - (client.descriptors.page.listJobs.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listJobsStream with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listJobsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Job[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Job) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listJobs, request), + ); + assert( + (client.descriptors.page.listJobs.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listJobs without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), - ]; - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4beta1.IJob[] = []; - const iterable = client.listJobsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listJobs without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Job()), + ]; + client.descriptors.page.listJobs.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4beta1.IJob[] = []; + const iterable = client.listJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listJobs with error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListJobsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListJobsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listJobsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4beta1.IJob[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listJobs.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listJobs with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListJobsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListJobsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listJobs.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listJobsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4beta1.IJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobs.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listJobs.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 jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + 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), + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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)); - }); + it('invokes getOperation without error using callback', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + 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)); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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 getOperation with error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + 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('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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 jobserviceModule.v4beta1.JobServiceClient({ - 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('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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 jobserviceModule.v4beta1.JobServiceClient({ + 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('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + 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('Path templates', () => { - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - 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('projectCompany', async () => { - const fakePath = "/rendered/path/projectCompany"; - const expectedParameters = { - project: "projectValue", - company: "companyValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCompanyPath', () => { - const result = client.projectCompanyPath("projectValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCompanyName', () => { - const result = client.matchProjectFromProjectCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectCompanyName', () => { - const result = client.matchCompanyFromProjectCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCompany', async () => { + const fakePath = '/rendered/path/projectCompany'; + const expectedParameters = { + project: 'projectValue', + company: 'companyValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCompanyPath', () => { + const result = client.projectCompanyPath( + 'projectValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCompanyName', () => { + const result = client.matchProjectFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectCompanyName', () => { + const result = client.matchCompanyFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectJob', async () => { - const fakePath = "/rendered/path/projectJob"; - const expectedParameters = { - project: "projectValue", - job: "jobValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectJobPath', () => { - const result = client.projectJobPath("projectValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectJobName', () => { - const result = client.matchProjectFromProjectJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectJobName', () => { - const result = client.matchJobFromProjectJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectJob', async () => { + const fakePath = '/rendered/path/projectJob'; + const expectedParameters = { + project: 'projectValue', + job: 'jobValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectJobPath', () => { + const result = client.projectJobPath('projectValue', 'jobValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectJobName', () => { + const result = client.matchProjectFromProjectJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectJobName', () => { + const result = client.matchJobFromProjectJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantCompany', async () => { - const fakePath = "/rendered/path/projectTenantCompany"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantCompanyPath', () => { - const result = client.projectTenantCompanyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantCompanyName', () => { - const result = client.matchProjectFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantCompanyName', () => { - const result = client.matchTenantFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectTenantCompanyName', () => { - const result = client.matchCompanyFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantCompany', async () => { + const fakePath = '/rendered/path/projectTenantCompany'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantCompanyPath', () => { + const result = client.projectTenantCompanyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantCompanyName', () => { + const result = + client.matchProjectFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantCompanyName', () => { + const result = client.matchTenantFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectTenantCompanyName', () => { + const result = + client.matchCompanyFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantJob', async () => { - const fakePath = "/rendered/path/projectTenantJob"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantJobPath', () => { - const result = client.projectTenantJobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantJobName', () => { - const result = client.matchProjectFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantJobName', () => { - const result = client.matchTenantFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectTenantJobName', () => { - const result = client.matchJobFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantJob', async () => { + const fakePath = '/rendered/path/projectTenantJob'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantJobPath', () => { + const result = client.projectTenantJobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantJobPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantJobName', () => { + const result = client.matchProjectFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantJobName', () => { + const result = client.matchTenantFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectTenantJobName', () => { + const result = client.matchJobFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new jobserviceModule.v4beta1.JobServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new jobserviceModule.v4beta1.JobServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_tenant_service_v4.ts b/packages/google-cloud-talent/test/gapic_tenant_service_v4.ts index 20b542abc30e..647453db41f7 100644 --- a/packages/google-cloud-talent/test/gapic_tenant_service_v4.ts +++ b/packages/google-cloud-talent/test/gapic_tenant_service_v4.ts @@ -19,1087 +19,1346 @@ 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 tenantserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v4.TenantServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new tenantserviceModule.v4.TenantServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new tenantserviceModule.v4.TenantServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('has universeDomain', () => { - const client = new tenantserviceModule.v4.TenantServiceClient(); - const universeDomain = client.universeDomain; - assert.strictEqual(universeDomain, "googleapis.com"); - }); + it('has universeDomain', () => { + const client = new tenantserviceModule.v4.TenantServiceClient(); + 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 = tenantserviceModule.v4.TenantServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = tenantserviceModule.v4.TenantServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new tenantserviceModule.v4.TenantServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 = + tenantserviceModule.v4.TenantServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + tenantserviceModule.v4.TenantServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new tenantserviceModule.v4.TenantServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4.TenantServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4.TenantServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4.TenantServiceClient({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 tenantserviceModule.v4.TenantServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - it('has port', () => { - const port = tenantserviceModule.v4.TenantServiceClient.port; - assert(port); - assert(typeof port === 'number'); + 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 tenantserviceModule.v4.TenantServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.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 no option', () => { - const client = new tenantserviceModule.v4.TenantServiceClient(); - assert(client); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new tenantserviceModule.v4.TenantServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('should create a client with gRPC fallback', () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - fallback: true, - }); - assert(client); - }); + it('has port', () => { + const port = tenantserviceModule.v4.TenantServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has initialize method and supports deferred initialization', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tenantServiceStub, undefined); - await client.initialize(); - assert(client.tenantServiceStub); - }); + it('should create a client with no option', () => { + const client = new tenantserviceModule.v4.TenantServiceClient(); + assert(client); + }); - it('has close method for the initialized client', done => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.tenantServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with gRPC fallback', () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has close method for the non-initialized client', done => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tenantServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has initialize method and supports deferred initialization', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.tenantServiceStub, undefined); + await client.initialize(); + assert(client.tenantServiceStub); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tenantserviceModule.v4.TenantServiceClient({ - 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 tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.tenantServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tenantserviceModule.v4.TenantServiceClient({ - 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 tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.tenantServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('createTenant', () => { - it('invokes createTenant without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.createTenant = stubSimpleCall(expectedResponse); - const [response] = await client.createTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant 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 tenantserviceModule.v4.TenantServiceClient({ + 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 createTenant without error using callback', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.createTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant 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 tenantserviceModule.v4.TenantServiceClient({ + 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('createTenant', () => { + it('invokes createTenant without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.createTenant = stubSimpleCall(expectedResponse); + const [response] = await client.createTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTenant with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTenant without error using callback', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.createTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTenant with closed client', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTenant(request), expectedError); - }); + it('invokes createTenant with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTenant', () => { - it('invokes getTenant without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.getTenant = stubSimpleCall(expectedResponse); - const [response] = await client.getTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTenant with closed client', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTenant(request), expectedError); + }); + }); + + describe('getTenant', () => { + it('invokes getTenant without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.getTenant = stubSimpleCall(expectedResponse); + const [response] = await client.getTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant without error using callback', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.getTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTenant without error using callback', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.getTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTenant with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTenant = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant with closed client', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTenant(request), expectedError); - }); + it('invokes getTenant with closed client', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTenant(request), expectedError); + }); + }); + + describe('updateTenant', () => { + it('invokes updateTenant without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.updateTenant = stubSimpleCall(expectedResponse); + const [response] = await client.updateTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTenant', () => { - it('invokes updateTenant without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.updateTenant = stubSimpleCall(expectedResponse); - const [response] = await client.updateTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTenant without error using callback', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4.Tenant(), + ); + client.innerApiCalls.updateTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant without error using callback', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4.Tenant() - ); - client.innerApiCalls.updateTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTenant with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTenant with closed client', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateTenant(request), expectedError); + }); + }); + + describe('deleteTenant', () => { + it('invokes deleteTenant without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTenant = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant with closed client', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateTenant(request), expectedError); - }); + it('invokes deleteTenant without error using callback', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTenant( + 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.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTenant', () => { - it('invokes deleteTenant without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTenant = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTenant with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant without error using callback', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTenant( - 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.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTenant with closed client', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTenant(request), expectedError); + }); + }); + + describe('listTenants', () => { + it('invokes listTenants without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + ]; + client.innerApiCalls.listTenants = stubSimpleCall(expectedResponse); + const [response] = await client.listTenants(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTenants without error using callback', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + ]; + client.innerApiCalls.listTenants = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTenants( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4.ITenant[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant with closed client', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTenant(request), expectedError); - }); + it('invokes listTenants with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTenants = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTenants(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTenants', () => { - it('invokes listTenants without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - ]; - client.innerApiCalls.listTenants = stubSimpleCall(expectedResponse); - const [response] = await client.listTenants(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listTenantsStream without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + ]; + client.descriptors.page.listTenants.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTenantsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Tenant[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Tenant) => { + responses.push(response); }); - - it('invokes listTenants without error using callback', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - ]; - client.innerApiCalls.listTenants = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTenants( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4.ITenant[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listTenants with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTenants = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTenants(request), expectedError); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants 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.listTenants.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTenants, request), + ); + assert( + (client.descriptors.page.listTenants.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTenantsStream without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - ]; - client.descriptors.page.listTenants.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTenantsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Tenant[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Tenant) => { - 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.listTenants.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTenants, request)); - assert( - (client.descriptors.page.listTenants.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listTenantsStream with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTenants.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listTenantsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4.Tenant[] = []; + stream.on('data', (response: protos.google.cloud.talent.v4.Tenant) => { + responses.push(response); }); - - it('invokes listTenantsStream with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTenants.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTenantsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4.Tenant[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4.Tenant) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTenants.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTenants, request)); - assert( - (client.descriptors.page.listTenants.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listTenants without error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), - ]; - client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4.ITenant[] = []; - const iterable = client.listTenantsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTenants.asyncIterate 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.listTenants.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTenants, request), + ); + assert( + (client.descriptors.page.listTenants.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTenants with error', async () => { - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTenantsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4.ITenant[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTenants without error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4.Tenant()), + ]; + client.descriptors.page.listTenants.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4.ITenant[] = []; + const iterable = client.listTenantsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTenants.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listTenants.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('company', async () => { - const fakePath = "/rendered/path/company"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.companyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.companyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('companyPath', () => { - const result = client.companyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.companyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromCompanyName', () => { - const result = client.matchProjectFromCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromCompanyName', () => { - const result = client.matchTenantFromCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromCompanyName', () => { - const result = client.matchCompanyFromCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.companyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + it('uses async iteration with listTenants with error', async () => { + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listTenantsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4.ITenant[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTenants.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listTenants.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('company', async () => { + const fakePath = '/rendered/path/company'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.companyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.companyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('companyPath', () => { + const result = client.companyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.companyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromCompanyName', () => { + const result = client.matchProjectFromCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromCompanyName', () => { + const result = client.matchTenantFromCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromCompanyName', () => { + const result = client.matchCompanyFromCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.companyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('job', async () => { - const fakePath = "/rendered/path/job"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.jobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.jobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('jobPath', () => { - const result = client.jobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.jobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromJobName', () => { - const result = client.matchProjectFromJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromJobName', () => { - const result = client.matchTenantFromJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromJobName', () => { - const result = client.matchJobFromJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.jobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('job', async () => { + const fakePath = '/rendered/path/job'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.jobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.jobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('jobPath', () => { + const result = client.jobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.jobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromJobName', () => { + const result = client.matchProjectFromJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromJobName', () => { + const result = client.matchTenantFromJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromJobName', () => { + const result = client.matchJobFromJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.jobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tenantserviceModule.v4.TenantServiceClient({ - 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 tenantserviceModule.v4.TenantServiceClient({ + 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('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new tenantserviceModule.v4.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new tenantserviceModule.v4.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/test/gapic_tenant_service_v4beta1.ts b/packages/google-cloud-talent/test/gapic_tenant_service_v4beta1.ts index 5ce89ed67553..f49b083b1eda 100644 --- a/packages/google-cloud-talent/test/gapic_tenant_service_v4beta1.ts +++ b/packages/google-cloud-talent/test/gapic_tenant_service_v4beta1.ts @@ -19,1163 +19,1470 @@ 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 tenantserviceModule from '../src'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf} from 'google-gax'; +import { protobuf } 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('v4beta1.TenantServiceClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient(); - 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 = tenantserviceModule.v4beta1.TenantServiceClient.servicePath; - assert.strictEqual(servicePath, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = tenantserviceModule.v4beta1.TenantServiceClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + }); - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.example.com'); - }); + it('has universeDomain', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.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 tenantserviceModule.v4beta1.TenantServiceClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4beta1.TenantServiceClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4beta1.TenantServiceClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + tenantserviceModule.v4beta1.TenantServiceClient.servicePath; + assert.strictEqual(servicePath, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + tenantserviceModule.v4beta1.TenantServiceClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'jobs.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('has port', () => { - const port = tenantserviceModule.v4beta1.TenantServiceClient.port; - assert(port); - assert(typeof port === 'number'); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.example.com'); + }); - it('should create a client with no option', () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient(); - 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 tenantserviceModule.v4beta1.TenantServiceClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.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 tenantserviceModule.v4beta1.TenantServiceClient({ - 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 tenantserviceModule.v4beta1.TenantServiceClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'jobs.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tenantServiceStub, undefined); - await client.initialize(); - assert(client.tenantServiceStub); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new tenantserviceModule.v4beta1.TenantServiceClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('has close method for the initialized client', done => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.tenantServiceStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('has port', () => { + const port = tenantserviceModule.v4beta1.TenantServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('has close method for the non-initialized client', done => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.tenantServiceStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); + it('should create a client with no option', () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient(); + assert(client); + }); - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - 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 tenantserviceModule.v4beta1.TenantServiceClient({ + fallback: true, + }); + assert(client); + }); - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - 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 tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.tenantServiceStub, undefined); + await client.initialize(); + assert(client.tenantServiceStub); }); - describe('createTenant', () => { - it('invokes createTenant without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.createTenant = stubSimpleCall(expectedResponse); - const [response] = await client.createTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant 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 tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.tenantServiceStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createTenant without error using callback', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.createTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant 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 tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.tenantServiceStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes createTenant with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.createTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTenant 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 tenantserviceModule.v4beta1.TenantServiceClient({ + 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 createTenant with closed client', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.CreateTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.CreateTenantRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTenant(request), expectedError); + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + 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('createTenant', () => { + it('invokes createTenant without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.createTenant = stubSimpleCall(expectedResponse); + const [response] = await client.createTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTenant', () => { - it('invokes getTenant without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.getTenant = stubSimpleCall(expectedResponse); - const [response] = await client.getTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTenant without error using callback', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.createTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant without error using callback', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.getTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTenant with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTenant with closed client', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.CreateTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.CreateTenantRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTenant(request), expectedError); + }); + }); + + describe('getTenant', () => { + it('invokes getTenant without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.getTenant = stubSimpleCall(expectedResponse); + const [response] = await client.getTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTenant with closed client', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.GetTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.GetTenantRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTenant(request), expectedError); - }); + it('invokes getTenant without error using callback', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.getTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('updateTenant', () => { - it('invokes updateTenant without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.updateTenant = stubSimpleCall(expectedResponse); - const [response] = await client.updateTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTenant with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTenant = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant without error using callback', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.Tenant() - ); - client.innerApiCalls.updateTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateTenant( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ITenant|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTenant with closed client', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.GetTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.GetTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTenant(request), expectedError); + }); + }); + + describe('updateTenant', () => { + it('invokes updateTenant without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.updateTenant = stubSimpleCall(expectedResponse); + const [response] = await client.updateTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTenant without error using callback', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.Tenant(), + ); + client.innerApiCalls.updateTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateTenant( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ITenant | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes updateTenant with closed client', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.UpdateTenantRequest() - ); - request.tenant ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.UpdateTenantRequest', ['tenant', 'name']); - request.tenant.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateTenant(request), expectedError); - }); + it('invokes updateTenant with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedHeaderRequestParams = `tenant.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTenant', () => { - it('invokes deleteTenant without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTenant = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTenant(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateTenant with closed client', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.UpdateTenantRequest(), + ); + request.tenant ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.UpdateTenantRequest', + ['tenant', 'name'], + ); + request.tenant.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateTenant(request), expectedError); + }); + }); + + describe('deleteTenant', () => { + it('invokes deleteTenant without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTenant = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTenant(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant without error using callback', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTenant = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTenant( - 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.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTenant without error using callback', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTenant = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTenant( + 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.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTenant = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTenant(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTenant as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTenant with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTenant = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTenant(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTenant as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTenant with closed client', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.DeleteTenantRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.DeleteTenantRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTenant(request), expectedError); - }); + it('invokes deleteTenant with closed client', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.DeleteTenantRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.DeleteTenantRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTenant(request), expectedError); + }); + }); + + describe('listTenants', () => { + it('invokes listTenants without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + ]; + client.innerApiCalls.listTenants = stubSimpleCall(expectedResponse); + const [response] = await client.listTenants(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTenants', () => { - it('invokes listTenants without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - ]; - client.innerApiCalls.listTenants = stubSimpleCall(expectedResponse); - const [response] = await client.listTenants(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTenants without error using callback', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + ]; + client.innerApiCalls.listTenants = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTenants( + request, + ( + err?: Error | null, + result?: protos.google.cloud.talent.v4beta1.ITenant[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTenants without error using callback', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - ]; - client.innerApiCalls.listTenants = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTenants( - request, - (err?: Error|null, result?: protos.google.cloud.talent.v4beta1.ITenant[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTenants with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTenants = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listTenants(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTenants as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTenants with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTenants = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTenants(request), expectedError); - const actualRequest = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTenants as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + it('invokes listTenantsStream without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + ]; + client.descriptors.page.listTenants.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTenantsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Tenant[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Tenant) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('invokes listTenantsStream without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - ]; - client.descriptors.page.listTenants.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTenantsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Tenant[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Tenant) => { - 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.listTenants.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTenants, request)); - assert( - (client.descriptors.page.listTenants.createStream 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.listTenants.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTenants, request), + ); + assert( + (client.descriptors.page.listTenants.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTenantsStream with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTenants.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTenantsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.talent.v4beta1.Tenant[] = []; - stream.on('data', (response: protos.google.cloud.talent.v4beta1.Tenant) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTenants.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTenants, request)); - assert( - (client.descriptors.page.listTenants.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); + it('invokes listTenantsStream with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTenants.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listTenantsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.talent.v4beta1.Tenant[] = []; + stream.on( + 'data', + (response: protos.google.cloud.talent.v4beta1.Tenant) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); }); - - it('uses async iteration with listTenants without error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), - ]; - client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.talent.v4beta1.ITenant[] = []; - const iterable = client.listTenantsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTenants.asyncIterate 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.listTenants.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTenants, request), + ); + assert( + (client.descriptors.page.listTenants.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTenants with error', async () => { - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.talent.v4beta1.ListTenantsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.talent.v4beta1.ListTenantsRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTenantsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.talent.v4beta1.ITenant[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTenants.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTenants without error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + generateSampleMessage(new protos.google.cloud.talent.v4beta1.Tenant()), + ]; + client.descriptors.page.listTenants.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.talent.v4beta1.ITenant[] = []; + const iterable = client.listTenantsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTenants.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listTenants.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); }); - describe('Path templates', () => { - - describe('project', async () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - 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('uses async iteration with listTenants with error', async () => { + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.talent.v4beta1.ListTenantsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.talent.v4beta1.ListTenantsRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTenants.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listTenantsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.talent.v4beta1.ITenant[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTenants.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listTenants.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('Path templates', () => { + describe('project', async () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + 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('projectCompany', async () => { - const fakePath = "/rendered/path/projectCompany"; - const expectedParameters = { - project: "projectValue", - company: "companyValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectCompanyPath', () => { - const result = client.projectCompanyPath("projectValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectCompanyName', () => { - const result = client.matchProjectFromProjectCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectCompanyName', () => { - const result = client.matchCompanyFromProjectCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectCompany', async () => { + const fakePath = '/rendered/path/projectCompany'; + const expectedParameters = { + project: 'projectValue', + company: 'companyValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectCompanyPath', () => { + const result = client.projectCompanyPath( + 'projectValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectCompanyPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectCompanyName', () => { + const result = client.matchProjectFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectCompanyName', () => { + const result = client.matchCompanyFromProjectCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + (client.pathTemplates.projectCompanyPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectJob', async () => { - const fakePath = "/rendered/path/projectJob"; - const expectedParameters = { - project: "projectValue", - job: "jobValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectJobPath', () => { - const result = client.projectJobPath("projectValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectJobName', () => { - const result = client.matchProjectFromProjectJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectJobName', () => { - const result = client.matchJobFromProjectJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectJob', async () => { + const fakePath = '/rendered/path/projectJob'; + const expectedParameters = { + project: 'projectValue', + job: 'jobValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectJobPath', () => { + const result = client.projectJobPath('projectValue', 'jobValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectJobPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectJobName', () => { + const result = client.matchProjectFromProjectJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectJobName', () => { + const result = client.matchJobFromProjectJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantCompany', async () => { - const fakePath = "/rendered/path/projectTenantCompany"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - company: "companyValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantCompanyPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantCompanyPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantCompanyPath', () => { - const result = client.projectTenantCompanyPath("projectValue", "tenantValue", "companyValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantCompanyName', () => { - const result = client.matchProjectFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantCompanyName', () => { - const result = client.matchTenantFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchCompanyFromProjectTenantCompanyName', () => { - const result = client.matchCompanyFromProjectTenantCompanyName(fakePath); - assert.strictEqual(result, "companyValue"); - assert((client.pathTemplates.projectTenantCompanyPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantCompany', async () => { + const fakePath = '/rendered/path/projectTenantCompany'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + company: 'companyValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantCompanyPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantCompanyPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantCompanyPath', () => { + const result = client.projectTenantCompanyPath( + 'projectValue', + 'tenantValue', + 'companyValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantCompanyName', () => { + const result = + client.matchProjectFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantCompanyName', () => { + const result = client.matchTenantFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchCompanyFromProjectTenantCompanyName', () => { + const result = + client.matchCompanyFromProjectTenantCompanyName(fakePath); + assert.strictEqual(result, 'companyValue'); + assert( + ( + client.pathTemplates.projectTenantCompanyPathTemplate + .match as SinonStub + ) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('projectTenantJob', async () => { - const fakePath = "/rendered/path/projectTenantJob"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - job: "jobValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.projectTenantJobPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectTenantJobPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectTenantJobPath', () => { - const result = client.projectTenantJobPath("projectValue", "tenantValue", "jobValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectTenantJobPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectTenantJobName', () => { - const result = client.matchProjectFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromProjectTenantJobName', () => { - const result = client.matchTenantFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchJobFromProjectTenantJobName', () => { - const result = client.matchJobFromProjectTenantJobName(fakePath); - assert.strictEqual(result, "jobValue"); - assert((client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('projectTenantJob', async () => { + const fakePath = '/rendered/path/projectTenantJob'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + job: 'jobValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.projectTenantJobPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectTenantJobPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectTenantJobPath', () => { + const result = client.projectTenantJobPath( + 'projectValue', + 'tenantValue', + 'jobValue', + ); + assert.strictEqual(result, fakePath); + assert( + ( + client.pathTemplates.projectTenantJobPathTemplate + .render as SinonStub + ) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromProjectTenantJobName', () => { + const result = client.matchProjectFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromProjectTenantJobName', () => { + const result = client.matchTenantFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchJobFromProjectTenantJobName', () => { + const result = client.matchJobFromProjectTenantJobName(fakePath); + assert.strictEqual(result, 'jobValue'); + assert( + (client.pathTemplates.projectTenantJobPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('tenant', async () => { - const fakePath = "/rendered/path/tenant"; - const expectedParameters = { - project: "projectValue", - tenant: "tenantValue", - }; - const client = new tenantserviceModule.v4beta1.TenantServiceClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - client.pathTemplates.tenantPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tenantPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tenantPath', () => { - const result = client.tenantPath("projectValue", "tenantValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tenantPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTenantName', () => { - const result = client.matchProjectFromTenantName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTenantFromTenantName', () => { - const result = client.matchTenantFromTenantName(fakePath); - assert.strictEqual(result, "tenantValue"); - assert((client.pathTemplates.tenantPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('tenant', async () => { + const fakePath = '/rendered/path/tenant'; + const expectedParameters = { + project: 'projectValue', + tenant: 'tenantValue', + }; + const client = new tenantserviceModule.v4beta1.TenantServiceClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + client.pathTemplates.tenantPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tenantPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tenantPath', () => { + const result = client.tenantPath('projectValue', 'tenantValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tenantPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTenantName', () => { + const result = client.matchProjectFromTenantName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTenantFromTenantName', () => { + const result = client.matchTenantFromTenantName(fakePath); + assert.strictEqual(result, 'tenantValue'); + assert( + (client.pathTemplates.tenantPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-talent/webpack.config.js b/packages/google-cloud-talent/webpack.config.js index bc29021737b8..f38000fc18f1 100644 --- a/packages/google-cloud-talent/webpack.config.js +++ b/packages/google-cloud-talent/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-tasks/.eslintignore b/packages/google-cloud-tasks/.eslintignore new file mode 100644 index 000000000000..a73044f809ca --- /dev/null +++ b/packages/google-cloud-tasks/.eslintignore @@ -0,0 +1,11 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/ +esm/src/**/*.d.ts +esm/test/**/*.d.ts +esm/system-test/**/*.d.ts +esm/system-test/fixtures/sample/src/*.ts \ No newline at end of file diff --git a/packages/google-cloud-tasks/.eslintrc.json b/packages/google-cloud-tasks/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-tasks/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-tasks/README.md b/packages/google-cloud-tasks/README.md index 718c9e8ffd44..1ba94e970dde 100644 --- a/packages/google-cloud-tasks/README.md +++ b/packages/google-cloud-tasks/README.md @@ -147,7 +147,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-tasks/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`) @@ -157,7 +157,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-tasks/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-tasks/esm/src/json-helper.cjs b/packages/google-cloud-tasks/esm/src/json-helper.cjs index 32fbac87ef1b..3c1fc730201e 100644 --- a/packages/google-cloud-tasks/esm/src/json-helper.cjs +++ b/packages/google-cloud-tasks/esm/src/json-helper.cjs @@ -1,4 +1,4 @@ -// Copyright 2026 Google LLC +// Copyright 2024 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-tasks/esm/src/v2/cloud_tasks_client.ts b/packages/google-cloud-tasks/esm/src/v2/cloud_tasks_client.ts index 9741bfbe6fae..71b3c433d9dd 100644 --- a/packages/google-cloud-tasks/esm/src/v2/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/esm/src/v2/cloud_tasks_client.ts @@ -18,15 +18,24 @@ /* global window */ import * 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'; // @ts-ignore import type * as protos from '../../../protos/protos.js'; import * as cloud_tasks_client_config from './cloud_tasks_client_config.json'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; -import {getJSON} from '../json-helper.cjs'; +import { fileURLToPath } from 'url'; +import { getJSON } from '../json-helper.cjs'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -36,15 +45,15 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); * This file defines retry strategy and timeouts for all API methods in this library. */ const gapicConfig = getJSON( - path.join(dirname, 'cloud_tasks_client_config.json') + path.join(dirname, 'cloud_tasks_client_config.json'), ); const jsonProtos = getJSON( - path.join(dirname, '..', '..', '..', 'protos/protos.json') + path.join(dirname, '..', '..', '..', 'protos/protos.json'), ); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; const version = getJSON( - path.join(dirname, '..', '..', '..', '..', 'package.json') + path.join(dirname, '..', '..', '..', '..', 'package.json'), ).version; /** @@ -60,7 +69,7 @@ export class CloudTasksClient { 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('tasks'); @@ -72,10 +81,10 @@ export class CloudTasksClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudTasksStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + cloudTasksStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudTasksClient. @@ -117,21 +126,42 @@ export class CloudTasksClient { * const client = new CloudTasksClient({fallback: 'rest'}, 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 CloudTasksClient; - 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 = 'cloudtasks.' + 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; @@ -156,7 +186,7 @@ export class CloudTasksClient { 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; @@ -170,18 +200,14 @@ export class CloudTasksClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Add ESM headers const isEsm = true; const isEsmString = isEsm ? '-esm' : '-cjs'; // 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}${isEsmString}`); } else { @@ -189,7 +215,7 @@ export class CloudTasksClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { + } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -197,23 +223,25 @@ export class CloudTasksClient { } // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos as gax.protobuf.INamespace); + this._protos = this._gaxGrpc.loadProtoJSON( + jsonProtos as gax.protobuf.INamespace, + ); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), queuePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}' + 'projects/{project}/locations/{location}/queues/{queue}', ), taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}' + 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}', ), }; @@ -221,16 +249,25 @@ export class CloudTasksClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listQueues: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'queues'), - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + listQueues: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'queues', + ), + listTasks: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tasks', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.tasks.v2.CloudTasks', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.tasks.v2.CloudTasks', + 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 @@ -261,37 +298,57 @@ export class CloudTasksClient { // Put together the "service stub" for // google.cloud.tasks.v2.CloudTasks. this.cloudTasksStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.tasks.v2.CloudTasks') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.tasks.v2.CloudTasks', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2.CloudTasks, - 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 cloudTasksStubMethods = - ['listQueues', 'getQueue', 'createQueue', 'updateQueue', 'deleteQueue', 'purgeQueue', 'pauseQueue', 'resumeQueue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions', 'listTasks', 'getTask', 'createTask', 'deleteTask', 'runTask']; + const cloudTasksStubMethods = [ + 'listQueues', + 'getQueue', + 'createQueue', + 'updateQueue', + 'deleteQueue', + 'purgeQueue', + 'pauseQueue', + 'resumeQueue', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + 'listTasks', + 'getTask', + 'createTask', + 'deleteTask', + 'runTask', + ]; for (const methodName of cloudTasksStubMethods) { const callPromise = this.cloudTasksStub.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; @@ -306,8 +363,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -319,8 +382,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -351,9 +420,7 @@ export class CloudTasksClient { * @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; @@ -362,8 +429,9 @@ export class CloudTasksClient { * 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; @@ -374,1665 +442,2114 @@ export class CloudTasksClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets a queue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the queue. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.get_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_GetQueue_async - */ + /** + * Gets a queue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the queue. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.get_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_GetQueue_async + */ getQueue( - request?: protos.google.cloud.tasks.v2.IGetQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IGetQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | undefined, + {} | undefined, + ] + >; getQueue( - request: protos.google.cloud.tasks.v2.IGetQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IGetQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request: protos.google.cloud.tasks.v2.IGetQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IGetQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request?: protos.google.cloud.tasks.v2.IGetQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IGetQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IGetQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('getQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IGetQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name in which the queue will be created. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * - * The list of allowed locations can be obtained by calling Cloud - * Tasks' implementation of - * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. - * @param {google.cloud.tasks.v2.Queue} request.queue - * Required. The queue to create. - * - * {@link protos.google.cloud.tasks.v2.Queue.name|Queue's name} cannot be the same as an - * existing queue. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.create_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_CreateQueue_async - */ + /** + * Creates a queue. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name in which the queue will be created. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * + * The list of allowed locations can be obtained by calling Cloud + * Tasks' implementation of + * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. + * @param {google.cloud.tasks.v2.Queue} request.queue + * Required. The queue to create. + * + * {@link protos.google.cloud.tasks.v2.Queue.name|Queue's name} cannot be the same as an + * existing queue. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.create_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_CreateQueue_async + */ createQueue( - request?: protos.google.cloud.tasks.v2.ICreateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.ICreateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | undefined, + {} | undefined, + ] + >; createQueue( - request: protos.google.cloud.tasks.v2.ICreateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.ICreateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request: protos.google.cloud.tasks.v2.ICreateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.ICreateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request?: protos.google.cloud.tasks.v2.ICreateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.ICreateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.ICreateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('createQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.ICreateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a queue. - * - * This method creates the queue if it does not exist and updates - * the queue if it does exist. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.tasks.v2.Queue} request.queue - * Required. The queue to create or update. - * - * The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} must be specified. - * - * Output only fields cannot be modified using UpdateQueue. - * Any value specified for an output only field will be ignored. - * The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} cannot be changed. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the queue are being updated. - * - * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.update_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_UpdateQueue_async - */ + /** + * Updates a queue. + * + * This method creates the queue if it does not exist and updates + * the queue if it does exist. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.tasks.v2.Queue} request.queue + * Required. The queue to create or update. + * + * The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} must be specified. + * + * Output only fields cannot be modified using UpdateQueue. + * Any value specified for an output only field will be ignored. + * The queue's {@link protos.google.cloud.tasks.v2.Queue.name|name} cannot be changed. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the queue are being updated. + * + * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.update_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_UpdateQueue_async + */ updateQueue( - request?: protos.google.cloud.tasks.v2.IUpdateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IUpdateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | undefined, + {} | undefined, + ] + >; updateQueue( - request: protos.google.cloud.tasks.v2.IUpdateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IUpdateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request: protos.google.cloud.tasks.v2.IUpdateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IUpdateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request?: protos.google.cloud.tasks.v2.IUpdateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IUpdateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'queue.name': request.queue!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'queue.name': request.queue!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.updateQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IUpdateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('updateQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IUpdateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * This command will delete the queue even if it has tasks in it. - * - * Note: If you delete a queue, a queue with the same name can't be created - * for 7 days. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2/cloud_tasks.delete_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteQueue_async - */ + /** + * Deletes a queue. + * + * This command will delete the queue even if it has tasks in it. + * + * Note: If you delete a queue, a queue with the same name can't be created + * for 7 days. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2/cloud_tasks.delete_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteQueue_async + */ deleteQueue( - request?: protos.google.cloud.tasks.v2.IDeleteQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IDeleteQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | undefined, + {} | undefined, + ] + >; deleteQueue( - request: protos.google.cloud.tasks.v2.IDeleteQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IDeleteQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request: protos.google.cloud.tasks.v2.IDeleteQueueRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IDeleteQueueRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request?: protos.google.cloud.tasks.v2.IDeleteQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IDeleteQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteQueue request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Purges a queue by deleting all of its tasks. - * - * All tasks created before this method is called are permanently deleted. - * - * Purge operations can take up to one minute to take effect. Tasks - * might be dispatched before the purge takes effect. A purge is irreversible. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.purge_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_PurgeQueue_async - */ + /** + * Purges a queue by deleting all of its tasks. + * + * All tasks created before this method is called are permanently deleted. + * + * Purge operations can take up to one minute to take effect. Tasks + * might be dispatched before the purge takes effect. A purge is irreversible. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.purge_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_PurgeQueue_async + */ purgeQueue( - request?: protos.google.cloud.tasks.v2.IPurgeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IPurgeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | undefined, + {} | undefined, + ] + >; purgeQueue( - request: protos.google.cloud.tasks.v2.IPurgeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IPurgeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request: protos.google.cloud.tasks.v2.IPurgeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IPurgeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request?: protos.google.cloud.tasks.v2.IPurgeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IPurgeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('purgeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('purgeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.purgeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPurgeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('purgeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .purgeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPurgeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('purgeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Pauses the queue. - * - * If a queue is paused then the system will stop dispatching tasks - * until the queue is resumed via - * {@link protos.google.cloud.tasks.v2.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can - * still be added when the queue is paused. A queue is paused if its - * {@link protos.google.cloud.tasks.v2.Queue.state|state} is - * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.pause_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_PauseQueue_async - */ + /** + * Pauses the queue. + * + * If a queue is paused then the system will stop dispatching tasks + * until the queue is resumed via + * {@link protos.google.cloud.tasks.v2.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can + * still be added when the queue is paused. A queue is paused if its + * {@link protos.google.cloud.tasks.v2.Queue.state|state} is + * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.pause_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_PauseQueue_async + */ pauseQueue( - request?: protos.google.cloud.tasks.v2.IPauseQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IPauseQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | undefined, + {} | undefined, + ] + >; pauseQueue( - request: protos.google.cloud.tasks.v2.IPauseQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IPauseQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request: protos.google.cloud.tasks.v2.IPauseQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IPauseQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request?: protos.google.cloud.tasks.v2.IPauseQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IPauseQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('pauseQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('pauseQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.pauseQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IPauseQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('pauseQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .pauseQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IPauseQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('pauseQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Resume a queue. - * - * This method resumes a queue after it has been - * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED} or - * {@link protos.google.cloud.tasks.v2.Queue.State.DISABLED|DISABLED}. The state of a - * queue is stored in the queue's {@link protos.google.cloud.tasks.v2.Queue.state|state}; - * after calling this method it will be set to - * {@link protos.google.cloud.tasks.v2.Queue.State.RUNNING|RUNNING}. - * - * WARNING: Resuming many high-QPS queues at the same time can - * lead to target overloading. If you are resuming high-QPS - * queues, follow the 500/50/5 pattern described in - * [Managing Cloud Tasks Scaling - * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. - * Please see the {@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/cloud_tasks.resume_queue.js - * region_tag:cloudtasks_v2_generated_CloudTasks_ResumeQueue_async - */ + /** + * Resume a queue. + * + * This method resumes a queue after it has been + * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED} or + * {@link protos.google.cloud.tasks.v2.Queue.State.DISABLED|DISABLED}. The state of a + * queue is stored in the queue's {@link protos.google.cloud.tasks.v2.Queue.state|state}; + * after calling this method it will be set to + * {@link protos.google.cloud.tasks.v2.Queue.State.RUNNING|RUNNING}. + * + * WARNING: Resuming many high-QPS queues at the same time can + * lead to target overloading. If you are resuming high-QPS + * queues, follow the 500/50/5 pattern described in + * [Managing Cloud Tasks Scaling + * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2.Queue|Queue}. + * Please see the {@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/cloud_tasks.resume_queue.js + * region_tag:cloudtasks_v2_generated_CloudTasks_ResumeQueue_async + */ resumeQueue( - request?: protos.google.cloud.tasks.v2.IResumeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IResumeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | undefined, + {} | undefined, + ] + >; resumeQueue( - request: protos.google.cloud.tasks.v2.IResumeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IResumeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; resumeQueue( - request: protos.google.cloud.tasks.v2.IResumeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IResumeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; resumeQueue( - request?: protos.google.cloud.tasks.v2.IResumeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IResumeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resumeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resumeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.resumeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.IQueue, - protos.google.cloud.tasks.v2.IResumeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('resumeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resumeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.IQueue, + protos.google.cloud.tasks.v2.IResumeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('resumeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.getIamPolicy` - * - * @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 {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/cloud_tasks.get_iam_policy.js - * region_tag:cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async - */ + /** + * Gets the access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.getIamPolicy` + * + * @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 {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/cloud_tasks.get_iam_policy.js + * region_tag:cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('getIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('getIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Sets the access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}. - * Replaces any existing policy. - * - * Note: The Cloud Console does not check queue-level IAM permissions yet. - * Project-level permissions are required to use the Cloud Console. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.setIamPolicy` - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@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/cloud_tasks.set_iam_policy.js - * region_tag:cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async - */ + /** + * Sets the access control policy for a {@link protos.google.cloud.tasks.v2.Queue|Queue}. + * Replaces any existing policy. + * + * Note: The Cloud Console does not check queue-level IAM permissions yet. + * Project-level permissions are required to use the Cloud Console. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.setIamPolicy` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@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/cloud_tasks.set_iam_policy.js + * region_tag:cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('setIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('setIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('setIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .setIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('setIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 permissions that a caller has on a - * {@link protos.google.cloud.tasks.v2.Queue|Queue}. If the resource does not exist, this - * will return an empty set of permissions, not a - * {@link protos.google.rpc.Code.NOT_FOUND|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 - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@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/cloud_tasks.test_iam_permissions.js - * region_tag:cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on a + * {@link protos.google.cloud.tasks.v2.Queue|Queue}. If the resource does not exist, this + * will return an empty set of permissions, not a + * {@link protos.google.rpc.Code.NOT_FOUND|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 + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@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/cloud_tasks.test_iam_permissions.js + * region_tag:cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('testIamPermissions request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('testIamPermissions response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]) => { - this._log.info('testIamPermissions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .testIamPermissions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('testIamPermissions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. - * Please see the {@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/cloud_tasks.get_task.js - * region_tag:cloudtasks_v2_generated_CloudTasks_GetTask_async - */ + /** + * Gets a task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. + * Please see the {@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/cloud_tasks.get_task.js + * region_tag:cloudtasks_v2_generated_CloudTasks_GetTask_async + */ getTask( - request?: protos.google.cloud.tasks.v2.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IGetTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | undefined, + {} | undefined, + ] + >; getTask( - request: protos.google.cloud.tasks.v2.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request: protos.google.cloud.tasks.v2.IGetTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IGetTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request?: protos.google.cloud.tasks.v2.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IGetTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IGetTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('getTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IGetTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task and adds it to a queue. - * - * Tasks cannot be updated after creation; there is no UpdateTask command. - * - * * The maximum task size is 100KB. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * - * The queue must already exist. - * @param {google.cloud.tasks.v2.Task} request.task - * Required. The task to add. - * - * Task names have the following format: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. - * The user can optionally specify a task - * {@link protos.google.cloud.tasks.v2.Task.name|name}. If a name is not specified then - * the system will generate a random unique task id, which will be set in the - * task returned in the {@link protos.google.cloud.tasks.v2.Task.name|response}. - * - * If {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} is not set or - * is in the past then Cloud Tasks will set it to the current time. - * - * Task De-duplication: - * - * Explicitly specifying a task ID enables task de-duplication. If - * a task's ID is identical to that of an existing task or a task - * that was deleted or executed recently then the call will fail - * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. - * If the task's queue was created using Cloud Tasks, then another task with - * the same name can't be created for ~1hour after the original task was - * deleted or executed. If the task's queue was created using queue.yaml or - * queue.xml, then another task with the same name can't be created - * for ~9days after the original task was deleted or executed. - * - * Because there is an extra lookup cost to identify duplicate task - * names, these {@link protos.google.cloud.tasks.v2.CloudTasks.CreateTask|CreateTask} - * calls have significantly increased latency. Using hashed strings for the - * task id or for the prefix of the task id is recommended. Choosing task ids - * that are sequential or have sequential prefixes, for example using a - * timestamp, causes an increase in latency and error rates in all - * task commands. The infrastructure relies on an approximately - * uniform distribution of task ids to store and serve tasks - * efficiently. - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. - * Please see the {@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/cloud_tasks.create_task.js - * region_tag:cloudtasks_v2_generated_CloudTasks_CreateTask_async - */ + /** + * Creates a task and adds it to a queue. + * + * Tasks cannot be updated after creation; there is no UpdateTask command. + * + * * The maximum task size is 100KB. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * + * The queue must already exist. + * @param {google.cloud.tasks.v2.Task} request.task + * Required. The task to add. + * + * Task names have the following format: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. + * The user can optionally specify a task + * {@link protos.google.cloud.tasks.v2.Task.name|name}. If a name is not specified then + * the system will generate a random unique task id, which will be set in the + * task returned in the {@link protos.google.cloud.tasks.v2.Task.name|response}. + * + * If {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} is not set or + * is in the past then Cloud Tasks will set it to the current time. + * + * Task De-duplication: + * + * Explicitly specifying a task ID enables task de-duplication. If + * a task's ID is identical to that of an existing task or a task + * that was deleted or executed recently then the call will fail + * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. + * If the task's queue was created using Cloud Tasks, then another task with + * the same name can't be created for ~1hour after the original task was + * deleted or executed. If the task's queue was created using queue.yaml or + * queue.xml, then another task with the same name can't be created + * for ~9days after the original task was deleted or executed. + * + * Because there is an extra lookup cost to identify duplicate task + * names, these {@link protos.google.cloud.tasks.v2.CloudTasks.CreateTask|CreateTask} + * calls have significantly increased latency. Using hashed strings for the + * task id or for the prefix of the task id is recommended. Choosing task ids + * that are sequential or have sequential prefixes, for example using a + * timestamp, causes an increase in latency and error rates in all + * task commands. The infrastructure relies on an approximately + * uniform distribution of task ids to store and serve tasks + * efficiently. + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. + * Please see the {@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/cloud_tasks.create_task.js + * region_tag:cloudtasks_v2_generated_CloudTasks_CreateTask_async + */ createTask( - request?: protos.google.cloud.tasks.v2.ICreateTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.ICreateTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | undefined, + {} | undefined, + ] + >; createTask( - request: protos.google.cloud.tasks.v2.ICreateTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.ICreateTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request: protos.google.cloud.tasks.v2.ICreateTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.ICreateTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request?: protos.google.cloud.tasks.v2.ICreateTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.ICreateTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.ICreateTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('createTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.ICreateTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task. - * - * A task can be deleted if it is scheduled or dispatched. A task - * cannot be deleted if it has executed successfully or permanently - * failed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2/cloud_tasks.delete_task.js - * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteTask_async - */ + /** + * Deletes a task. + * + * A task can be deleted if it is scheduled or dispatched. A task + * cannot be deleted if it has executed successfully or permanently + * failed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2/cloud_tasks.delete_task.js + * region_tag:cloudtasks_v2_generated_CloudTasks_DeleteTask_async + */ deleteTask( - request?: protos.google.cloud.tasks.v2.IDeleteTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IDeleteTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | undefined, + {} | undefined, + ] + >; deleteTask( - request: protos.google.cloud.tasks.v2.IDeleteTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IDeleteTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request: protos.google.cloud.tasks.v2.IDeleteTaskRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IDeleteTaskRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request?: protos.google.cloud.tasks.v2.IDeleteTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IDeleteTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTask request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2.IDeleteTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2.IDeleteTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Forces a task to run now. - * - * When this method is called, Cloud Tasks will dispatch the task, even if - * the task is already running, the queue has reached its - * {@link protos.google.cloud.tasks.v2.RateLimits|RateLimits} or is - * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}. - * - * This command is meant to be used for manual debugging. For - * example, {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} can be used to - * retry a failed task after a fix has been made or to manually force a task - * to be dispatched now. - * - * The dispatched task is returned. That is, the task that is returned - * contains the {@link protos.Task.status|status} after the task is dispatched but - * before the task is received by its target. - * - * If Cloud Tasks receives a successful response from the task's - * target, then the task will be deleted; otherwise the task's - * {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} will be reset to - * the time that {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} was - * called plus the retry delay specified in the queue's - * {@link protos.google.cloud.tasks.v2.RetryConfig|RetryConfig}. - * - * {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} returns - * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a - * task that has already succeeded or permanently failed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. - * Please see the {@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/cloud_tasks.run_task.js - * region_tag:cloudtasks_v2_generated_CloudTasks_RunTask_async - */ + /** + * Forces a task to run now. + * + * When this method is called, Cloud Tasks will dispatch the task, even if + * the task is already running, the queue has reached its + * {@link protos.google.cloud.tasks.v2.RateLimits|RateLimits} or is + * {@link protos.google.cloud.tasks.v2.Queue.State.PAUSED|PAUSED}. + * + * This command is meant to be used for manual debugging. For + * example, {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} can be used to + * retry a failed task after a fix has been made or to manually force a task + * to be dispatched now. + * + * The dispatched task is returned. That is, the task that is returned + * contains the {@link protos.Task.status|status} after the task is dispatched but + * before the task is received by its target. + * + * If Cloud Tasks receives a successful response from the task's + * target, then the task will be deleted; otherwise the task's + * {@link protos.google.cloud.tasks.v2.Task.schedule_time|schedule_time} will be reset to + * the time that {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} was + * called plus the retry delay specified in the queue's + * {@link protos.google.cloud.tasks.v2.RetryConfig|RetryConfig}. + * + * {@link protos.google.cloud.tasks.v2.CloudTasks.RunTask|RunTask} returns + * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a + * task that has already succeeded or permanently failed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} 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.tasks.v2.Task|Task}. + * Please see the {@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/cloud_tasks.run_task.js + * region_tag:cloudtasks_v2_generated_CloudTasks_RunTask_async + */ runTask( - request?: protos.google.cloud.tasks.v2.IRunTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2.IRunTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | undefined, + {} | undefined, + ] + >; runTask( - request: protos.google.cloud.tasks.v2.IRunTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IRunTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request: protos.google.cloud.tasks.v2.IRunTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2.IRunTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request?: protos.google.cloud.tasks.v2.IRunTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2.IRunTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('runTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('runTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.runTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2.ITask, - protos.google.cloud.tasks.v2.IRunTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('runTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .runTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2.ITask, + protos.google.cloud.tasks.v2.IRunTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('runTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queues. - * - * Queues are returned in lexicographical order. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an - * error to switch the value of the - * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating - * through pages. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2.Queue|Queue}. - * 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 queues. + * + * Queues are returned in lexicographical order. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an + * error to switch the value of the + * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating + * through pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2.Queue|Queue}. + * 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueues( - request?: protos.google.cloud.tasks.v2.IListQueuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.IQueue[], - protos.google.cloud.tasks.v2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2.IListQueuesResponse - ]>; + request?: protos.google.cloud.tasks.v2.IListQueuesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue[], + protos.google.cloud.tasks.v2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2.IListQueuesResponse, + ] + >; listQueues( - request: protos.google.cloud.tasks.v2.IListQueuesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2.IListQueuesRequest, - protos.google.cloud.tasks.v2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2.IQueue>): void; + request: protos.google.cloud.tasks.v2.IListQueuesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2.IListQueuesRequest, + protos.google.cloud.tasks.v2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2.IQueue + >, + ): void; listQueues( - request: protos.google.cloud.tasks.v2.IListQueuesRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2.IListQueuesRequest, - protos.google.cloud.tasks.v2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2.IQueue>): void; + request: protos.google.cloud.tasks.v2.IListQueuesRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2.IListQueuesRequest, + protos.google.cloud.tasks.v2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2.IQueue + >, + ): void; listQueues( - request?: protos.google.cloud.tasks.v2.IListQueuesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2.IListQueuesRequest, - protos.google.cloud.tasks.v2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2.IQueue>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2.IListQueuesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2.IListQueuesRequest, - protos.google.cloud.tasks.v2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2.IQueue>): - Promise<[ - protos.google.cloud.tasks.v2.IQueue[], - protos.google.cloud.tasks.v2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2.IListQueuesResponse - ]>|void { + protos.google.cloud.tasks.v2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2.IQueue + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2.IListQueuesRequest, + protos.google.cloud.tasks.v2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2.IQueue + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.IQueue[], + protos.google.cloud.tasks.v2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2.IListQueuesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2.IListQueuesRequest, - protos.google.cloud.tasks.v2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2.IQueue>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2.IListQueuesRequest, + protos.google.cloud.tasks.v2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2.IQueue + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listQueues values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -2041,280 +2558,299 @@ export class CloudTasksClient { this._log.info('listQueues request %j', request); return this.innerApiCalls .listQueues(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2.IQueue[], - protos.google.cloud.tasks.v2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2.IListQueuesResponse - ]) => { - this._log.info('listQueues values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2.IQueue[], + protos.google.cloud.tasks.v2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2.IListQueuesResponse, + ]) => { + this._log.info('listQueues values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listQueues`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an - * error to switch the value of the - * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating - * through pages. - * @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.tasks.v2.Queue|Queue} 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 `listQueues`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an + * error to switch the value of the + * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating + * through pages. + * @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.tasks.v2.Queue|Queue} 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueuesStream( - request?: protos.google.cloud.tasks.v2.IListQueuesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues stream %j', request); return this.descriptors.page.listQueues.createStream( this.innerApiCalls.listQueues as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listQueues`, 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 name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an - * error to switch the value of the - * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating - * through pages. - * @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.tasks.v2.Queue|Queue}. 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/cloud_tasks.list_queues.js - * region_tag:cloudtasks_v2_generated_CloudTasks_ListQueues_async - */ + /** + * Equivalent to `listQueues`, 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 name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListQueues|ListQueues} method. It is an + * error to switch the value of the + * {@link protos.google.cloud.tasks.v2.ListQueuesRequest.filter|filter} while iterating + * through pages. + * @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.tasks.v2.Queue|Queue}. 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/cloud_tasks.list_queues.js + * region_tag:cloudtasks_v2_generated_CloudTasks_ListQueues_async + */ listQueuesAsync( - request?: protos.google.cloud.tasks.v2.IListQueuesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues iterate %j', request); return this.descriptors.page.listQueues.asyncIterate( this.innerApiCalls['listQueues'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the tasks in a queue. - * - * By default, only the {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC} view is - * retrieved due to performance considerations; - * {@link protos.google.cloud.tasks.v2.ListTasksRequest.response_view|response_view} - * controls the subset of information which is returned. - * - * The tasks may be returned in any order. The ordering may change at any - * time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2.Task|Task}. - * 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 tasks in a queue. + * + * By default, only the {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC} view is + * retrieved due to performance considerations; + * {@link protos.google.cloud.tasks.v2.ListTasksRequest.response_view|response_view} + * controls the subset of information which is returned. + * + * The tasks may be returned in any order. The ordering may change at any + * time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2.Task|Task}. + * 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasks( - request?: protos.google.cloud.tasks.v2.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2.ITask[], - protos.google.cloud.tasks.v2.IListTasksRequest|null, - protos.google.cloud.tasks.v2.IListTasksResponse - ]>; + request?: protos.google.cloud.tasks.v2.IListTasksRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask[], + protos.google.cloud.tasks.v2.IListTasksRequest | null, + protos.google.cloud.tasks.v2.IListTasksResponse, + ] + >; listTasks( - request: protos.google.cloud.tasks.v2.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2.IListTasksRequest, - protos.google.cloud.tasks.v2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2.ITask>): void; + request: protos.google.cloud.tasks.v2.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2.IListTasksRequest, + protos.google.cloud.tasks.v2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2.ITask + >, + ): void; listTasks( - request: protos.google.cloud.tasks.v2.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2.IListTasksRequest, - protos.google.cloud.tasks.v2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2.ITask>): void; + request: protos.google.cloud.tasks.v2.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2.IListTasksRequest, + protos.google.cloud.tasks.v2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2.ITask + >, + ): void; listTasks( - request?: protos.google.cloud.tasks.v2.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2.IListTasksRequest, - protos.google.cloud.tasks.v2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2.ITask>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2.IListTasksRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2.IListTasksRequest, - protos.google.cloud.tasks.v2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2.ITask>): - Promise<[ - protos.google.cloud.tasks.v2.ITask[], - protos.google.cloud.tasks.v2.IListTasksRequest|null, - protos.google.cloud.tasks.v2.IListTasksResponse - ]>|void { + protos.google.cloud.tasks.v2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2.ITask + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2.IListTasksRequest, + protos.google.cloud.tasks.v2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2.ITask + >, + ): Promise< + [ + protos.google.cloud.tasks.v2.ITask[], + protos.google.cloud.tasks.v2.IListTasksRequest | null, + protos.google.cloud.tasks.v2.IListTasksResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2.IListTasksRequest, - protos.google.cloud.tasks.v2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2.ITask>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2.IListTasksRequest, + protos.google.cloud.tasks.v2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2.ITask + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTasks values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -2323,167 +2859,172 @@ export class CloudTasksClient { this._log.info('listTasks request %j', request); return this.innerApiCalls .listTasks(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2.ITask[], - protos.google.cloud.tasks.v2.IListTasksRequest|null, - protos.google.cloud.tasks.v2.IListTasksResponse - ]) => { - this._log.info('listTasks values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2.ITask[], + protos.google.cloud.tasks.v2.IListTasksRequest | null, + protos.google.cloud.tasks.v2.IListTasksResponse, + ]) => { + this._log.info('listTasks values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTasks`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2.Task|Task} 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 `listTasks`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2.Task|Task} 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasksStream( - request?: protos.google.cloud.tasks.v2.IListTasksRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks stream %j', request); return this.descriptors.page.listTasks.createStream( this.innerApiCalls.listTasks as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTasks`, 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 queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. - * - * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; - * not all information is retrieved by default because some data, such as - * payloads, might be desirable to return only when needed because - * of its large size or because of the sensitivity of data that it - * contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires - * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) - * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2.Task|Task}. 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/cloud_tasks.list_tasks.js - * region_tag:cloudtasks_v2_generated_CloudTasks_ListTasks_async - */ + /** + * Equivalent to `listTasks`, 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 queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2.Task|Task} will be returned. + * + * By default response_view is {@link protos.google.cloud.tasks.v2.Task.View.BASIC|BASIC}; + * not all information is retrieved by default because some data, such as + * payloads, might be desirable to return only when needed because + * of its large size or because of the sensitivity of data that it + * contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2.Task.View.FULL|FULL} requires + * `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + * permission on the {@link protos.google.cloud.tasks.v2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2.Task|Task}. 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/cloud_tasks.list_tasks.js + * region_tag:cloudtasks_v2_generated_CloudTasks_ListTasks_async + */ listTasksAsync( - request?: protos.google.cloud.tasks.v2.IListTasksRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks iterate %j', request); return this.descriptors.page.listTasks.asyncIterate( this.innerApiCalls['listTasks'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2518,12 +3059,11 @@ export class CloudTasksClient { | 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. @@ -2556,7 +3096,7 @@ export class CloudTasksClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -2572,7 +3112,7 @@ export class CloudTasksClient { * @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 +3147,7 @@ export class CloudTasksClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2632,7 +3172,7 @@ export class CloudTasksClient { * @param {string} queue * @returns {string} Resource name string. */ - queuePath(project:string,location:string,queue:string) { + queuePath(project: string, location: string, queue: string) { return this.pathTemplates.queuePathTemplate.render({ project: project, location: location, @@ -2682,7 +3222,7 @@ export class CloudTasksClient { * @param {string} task * @returns {string} Resource name string. */ - taskPath(project:string,location:string,queue:string,task:string) { + taskPath(project: string, location: string, queue: string, task: string) { return this.pathTemplates.taskPathTemplate.render({ project: project, location: location, @@ -2743,13 +3283,15 @@ export class CloudTasksClient { */ close(): Promise { if (this.cloudTasksStub && !this._terminated) { - return this.cloudTasksStub.then(stub => { + return this.cloudTasksStub.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-tasks/esm/src/v2/index.ts b/packages/google-cloud-tasks/esm/src/v2/index.ts index 9500073e7175..90d3c82528c5 100644 --- a/packages/google-cloud-tasks/esm/src/v2/index.ts +++ b/packages/google-cloud-tasks/esm/src/v2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudTasksClient} from './cloud_tasks_client.js'; +export { CloudTasksClient } from './cloud_tasks_client.js'; diff --git a/packages/google-cloud-tasks/esm/src/v2beta2/cloud_tasks_client.ts b/packages/google-cloud-tasks/esm/src/v2beta2/cloud_tasks_client.ts index 2bb6404a48e5..f5217fe2a6a0 100644 --- a/packages/google-cloud-tasks/esm/src/v2beta2/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/esm/src/v2beta2/cloud_tasks_client.ts @@ -18,15 +18,24 @@ /* global window */ import * 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'; // @ts-ignore import type * as protos from '../../../protos/protos.js'; import * as cloud_tasks_client_config from './cloud_tasks_client_config.json'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; -import {getJSON} from '../json-helper.cjs'; +import { fileURLToPath } from 'url'; +import { getJSON } from '../json-helper.cjs'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -36,15 +45,15 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); * This file defines retry strategy and timeouts for all API methods in this library. */ const gapicConfig = getJSON( - path.join(dirname, 'cloud_tasks_client_config.json') + path.join(dirname, 'cloud_tasks_client_config.json'), ); const jsonProtos = getJSON( - path.join(dirname, '..', '..', '..', 'protos/protos.json') + path.join(dirname, '..', '..', '..', 'protos/protos.json'), ); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; const version = getJSON( - path.join(dirname, '..', '..', '..', '..', 'package.json') + path.join(dirname, '..', '..', '..', '..', 'package.json'), ).version; /** @@ -60,7 +69,7 @@ export class CloudTasksClient { 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('tasks'); @@ -72,10 +81,10 @@ export class CloudTasksClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudTasksStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + cloudTasksStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudTasksClient. @@ -117,21 +126,42 @@ export class CloudTasksClient { * const client = new CloudTasksClient({fallback: 'rest'}, 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 CloudTasksClient; - 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 = 'cloudtasks.' + 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; @@ -156,7 +186,7 @@ export class CloudTasksClient { 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; @@ -170,18 +200,14 @@ export class CloudTasksClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Add ESM headers const isEsm = true; const isEsmString = isEsm ? '-esm' : '-cjs'; // 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}${isEsmString}`); } else { @@ -189,7 +215,7 @@ export class CloudTasksClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { + } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -197,23 +223,25 @@ export class CloudTasksClient { } // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos as gax.protobuf.INamespace); + this._protos = this._gaxGrpc.loadProtoJSON( + jsonProtos as gax.protobuf.INamespace, + ); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), queuePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}' + 'projects/{project}/locations/{location}/queues/{queue}', ), taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}' + 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}', ), }; @@ -221,16 +249,25 @@ export class CloudTasksClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listQueues: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'queues'), - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + listQueues: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'queues', + ), + listTasks: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tasks', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.tasks.v2beta2.CloudTasks', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.tasks.v2beta2.CloudTasks', + 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 @@ -261,37 +298,62 @@ export class CloudTasksClient { // Put together the "service stub" for // google.cloud.tasks.v2beta2.CloudTasks. this.cloudTasksStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.tasks.v2beta2.CloudTasks') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.tasks.v2beta2.CloudTasks', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2beta2.CloudTasks, - 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 cloudTasksStubMethods = - ['listQueues', 'getQueue', 'createQueue', 'updateQueue', 'deleteQueue', 'purgeQueue', 'pauseQueue', 'resumeQueue', 'uploadQueueYaml', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions', 'listTasks', 'getTask', 'createTask', 'deleteTask', 'leaseTasks', 'acknowledgeTask', 'renewLease', 'cancelLease', 'runTask']; + const cloudTasksStubMethods = [ + 'listQueues', + 'getQueue', + 'createQueue', + 'updateQueue', + 'deleteQueue', + 'purgeQueue', + 'pauseQueue', + 'resumeQueue', + 'uploadQueueYaml', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + 'listTasks', + 'getTask', + 'createTask', + 'deleteTask', + 'leaseTasks', + 'acknowledgeTask', + 'renewLease', + 'cancelLease', + 'runTask', + ]; for (const methodName of cloudTasksStubMethods) { const callPromise = this.cloudTasksStub.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; @@ -306,8 +368,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -319,8 +387,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -351,9 +425,7 @@ export class CloudTasksClient { * @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; @@ -362,8 +434,9 @@ export class CloudTasksClient { * 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; @@ -374,2339 +447,3012 @@ export class CloudTasksClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets a queue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the queue. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.get_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetQueue_async - */ + /** + * Gets a queue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the queue. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.get_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetQueue_async + */ getQueue( - request?: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | undefined, + {} | undefined, + ] + >; getQueue( - request: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request?: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IGetQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IGetQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('getQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IGetQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name in which the queue will be created. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * - * The list of allowed locations can be obtained by calling Cloud - * Tasks' implementation of - * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. - * @param {google.cloud.tasks.v2beta2.Queue} request.queue - * Required. The queue to create. - * - * {@link protos.google.cloud.tasks.v2beta2.Queue.name|Queue's name} cannot be the same as - * an existing queue. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.create_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_async - */ + /** + * Creates a queue. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name in which the queue will be created. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * + * The list of allowed locations can be obtained by calling Cloud + * Tasks' implementation of + * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. + * @param {google.cloud.tasks.v2beta2.Queue} request.queue + * Required. The queue to create. + * + * {@link protos.google.cloud.tasks.v2beta2.Queue.name|Queue's name} cannot be the same as + * an existing queue. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.create_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_async + */ createQueue( - request?: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | undefined, + {} | undefined, + ] + >; createQueue( - request: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request?: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.ICreateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.ICreateQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + | protos.google.cloud.tasks.v2beta2.ICreateQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.ICreateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('createQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.ICreateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a queue. - * - * This method creates the queue if it does not exist and updates - * the queue if it does exist. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.tasks.v2beta2.Queue} request.queue - * Required. The queue to create or update. - * - * The queue's {@link protos.google.cloud.tasks.v2beta2.Queue.name|name} must be - * specified. - * - * Output only fields cannot be modified using UpdateQueue. - * Any value specified for an output only field will be ignored. - * The queue's {@link protos.google.cloud.tasks.v2beta2.Queue.name|name} cannot be - * changed. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the queue are being updated. - * - * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.update_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_async - */ + /** + * Updates a queue. + * + * This method creates the queue if it does not exist and updates + * the queue if it does exist. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.tasks.v2beta2.Queue} request.queue + * Required. The queue to create or update. + * + * The queue's {@link protos.google.cloud.tasks.v2beta2.Queue.name|name} must be + * specified. + * + * Output only fields cannot be modified using UpdateQueue. + * Any value specified for an output only field will be ignored. + * The queue's {@link protos.google.cloud.tasks.v2beta2.Queue.name|name} cannot be + * changed. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the queue are being updated. + * + * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.update_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_async + */ updateQueue( - request?: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | undefined, + {} | undefined, + ] + >; updateQueue( - request: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request?: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'queue.name': request.queue!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'queue.name': request.queue!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + | protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.updateQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('updateQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IUpdateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * This command will delete the queue even if it has tasks in it. - * - * Note: If you delete a queue, a queue with the same name can't be created - * for 7 days. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2beta2/cloud_tasks.delete_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_async - */ + /** + * Deletes a queue. + * + * This command will delete the queue even if it has tasks in it. + * + * Note: If you delete a queue, a queue with the same name can't be created + * for 7 days. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2beta2/cloud_tasks.delete_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_async + */ deleteQueue( - request?: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | undefined, + {} | undefined, + ] + >; deleteQueue( - request: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request?: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteQueue request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Purges a queue by deleting all of its tasks. - * - * All tasks created before this method is called are permanently deleted. - * - * Purge operations can take up to one minute to take effect. Tasks - * might be dispatched before the purge takes effect. A purge is irreversible. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.purge_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_async - */ + /** + * Purges a queue by deleting all of its tasks. + * + * All tasks created before this method is called are permanently deleted. + * + * Purge operations can take up to one minute to take effect. Tasks + * might be dispatched before the purge takes effect. A purge is irreversible. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.purge_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_async + */ purgeQueue( - request?: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | undefined, + {} | undefined, + ] + >; purgeQueue( - request: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request?: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('purgeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + | protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('purgeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.purgeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('purgeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .purgeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPurgeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('purgeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Pauses the queue. - * - * If a queue is paused then the system will stop dispatching tasks - * until the queue is resumed via - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can - * still be added when the queue is paused. A queue is paused if its - * {@link protos.google.cloud.tasks.v2beta2.Queue.state|state} is - * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.pause_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_async - */ + /** + * Pauses the queue. + * + * If a queue is paused then the system will stop dispatching tasks + * until the queue is resumed via + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can + * still be added when the queue is paused. A queue is paused if its + * {@link protos.google.cloud.tasks.v2beta2.Queue.state|state} is + * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.pause_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_async + */ pauseQueue( - request?: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | undefined, + {} | undefined, + ] + >; pauseQueue( - request: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request?: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IPauseQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IPauseQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('pauseQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + | protos.google.cloud.tasks.v2beta2.IPauseQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('pauseQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.pauseQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IPauseQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('pauseQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .pauseQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IPauseQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('pauseQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Resume a queue. - * - * This method resumes a queue after it has been - * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED} or - * {@link protos.google.cloud.tasks.v2beta2.Queue.State.DISABLED|DISABLED}. The state of a - * queue is stored in the queue's - * {@link protos.google.cloud.tasks.v2beta2.Queue.state|state}; after calling this method - * it will be set to - * {@link protos.google.cloud.tasks.v2beta2.Queue.State.RUNNING|RUNNING}. - * - * WARNING: Resuming many high-QPS queues at the same time can - * lead to target overloading. If you are resuming high-QPS - * queues, follow the 500/50/5 pattern described in - * [Managing Cloud Tasks Scaling - * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.resume_queue.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_async - */ - resumeQueue( - request?: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|undefined, {}|undefined - ]>; - resumeQueue( - request: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; - resumeQueue( - request: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; - resumeQueue( - request?: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + /** + * Resume a queue. + * + * This method resumes a queue after it has been + * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED} or + * {@link protos.google.cloud.tasks.v2beta2.Queue.State.DISABLED|DISABLED}. The state of a + * queue is stored in the queue's + * {@link protos.google.cloud.tasks.v2beta2.Queue.state|state}; after calling this method + * it will be set to + * {@link protos.google.cloud.tasks.v2beta2.Queue.State.RUNNING|RUNNING}. + * + * WARNING: Resuming many high-QPS queues at the same time can + * lead to target overloading. If you are resuming high-QPS + * queues, follow the 500/50/5 pattern described in + * [Managing Cloud Tasks Scaling + * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta2.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.resume_queue.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_async + */ + resumeQueue( + request?: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | undefined, + {} | undefined, + ] + >; + resumeQueue( + request: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; + resumeQueue( + request: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; + resumeQueue( + request?: protos.google.cloud.tasks.v2beta2.IResumeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IResumeQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resumeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.IQueue, + | protos.google.cloud.tasks.v2beta2.IResumeQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resumeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.resumeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.IQueue, - protos.google.cloud.tasks.v2beta2.IResumeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('resumeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resumeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.IQueue, + protos.google.cloud.tasks.v2beta2.IResumeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('resumeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Update queue list by uploading a queue.yaml file. - * - * The queue.yaml file is supplied in the request body as a YAML encoded - * string. This method was added to support gcloud clients versions before - * 322.0.0. New clients should use CreateQueue instead of this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.appId - * Required. The App ID is supplied as an HTTP parameter. Unlike internal - * usage of App ID, it does not include a region prefix. Rather, the App ID - * represents the Project ID against which to make the request. - * @param {google.api.HttpBody} request.httpBody - * The http body contains the queue.yaml file which used to update queue lists - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v2beta2/cloud_tasks.upload_queue_yaml.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_async - */ + /** + * Update queue list by uploading a queue.yaml file. + * + * The queue.yaml file is supplied in the request body as a YAML encoded + * string. This method was added to support gcloud clients versions before + * 322.0.0. New clients should use CreateQueue instead of this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.appId + * Required. The App ID is supplied as an HTTP parameter. Unlike internal + * usage of App ID, it does not include a region prefix. Rather, the App ID + * represents the Project ID against which to make the request. + * @param {google.api.HttpBody} request.httpBody + * The http body contains the queue.yaml file which used to update queue lists + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v2beta2/cloud_tasks.upload_queue_yaml.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_UploadQueueYaml_async + */ uploadQueueYaml( - request?: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest | undefined, + {} | undefined, + ] + >; uploadQueueYaml( - request: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; uploadQueueYaml( - request: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest + | null + | undefined, + {} | null | undefined + >, + ): void; uploadQueueYaml( - request?: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('uploadQueueYaml request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('uploadQueueYaml response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.uploadQueueYaml(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest|undefined, {}|undefined - ]) => { - this._log.info('uploadQueueYaml response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .uploadQueueYaml(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IUploadQueueYamlRequest | undefined, + {} | undefined, + ]) => { + this._log.info('uploadQueueYaml response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 access control policy for a - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. Returns an empty policy if the - * resource exists and does not have a policy set. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.getIamPolicy` - * - * @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 {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.get_iam_policy.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async - */ + /** + * Gets the access control policy for a + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. Returns an empty policy if the + * resource exists and does not have a policy set. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.getIamPolicy` + * + * @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 {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.get_iam_policy.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('getIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('getIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Sets the access control policy for a - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. Replaces any existing policy. - * - * Note: The Cloud Console does not check queue-level IAM permissions yet. - * Project-level permissions are required to use the Cloud Console. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.setIamPolicy` - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.set_iam_policy.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async - */ + /** + * Sets the access control policy for a + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. Replaces any existing policy. + * + * Note: The Cloud Console does not check queue-level IAM permissions yet. + * Project-level permissions are required to use the Cloud Console. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.setIamPolicy` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.set_iam_policy.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('setIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('setIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('setIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .setIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('setIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 permissions that a caller has on a - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. If the resource does not exist, - * this will return an empty set of permissions, not a - * {@link protos.google.rpc.Code.NOT_FOUND|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 - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.test_iam_permissions.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on a + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue}. If the resource does not exist, + * this will return an empty set of permissions, not a + * {@link protos.google.rpc.Code.NOT_FOUND|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 + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.test_iam_permissions.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('testIamPermissions request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('testIamPermissions response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]) => { - this._log.info('testIamPermissions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .testIamPermissions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('testIamPermissions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.get_task.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetTask_async - */ + /** + * Gets a task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.get_task.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_GetTask_async + */ getTask( - request?: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | undefined, + {} | undefined, + ] + >; getTask( - request: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request?: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IGetTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IGetTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('getTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IGetTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task and adds it to a queue. - * - * Tasks cannot be updated after creation; there is no UpdateTask command. - * - * * For {@link protos.google.cloud.tasks.v2beta2.AppEngineHttpTarget|App Engine queues}, - * the maximum task size is - * 100KB. - * * For {@link protos.google.cloud.tasks.v2beta2.PullTarget|pull queues}, the maximum - * task size is 1MB. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * - * The queue must already exist. - * @param {google.cloud.tasks.v2beta2.Task} request.task - * Required. The task to add. - * - * Task names have the following format: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. - * The user can optionally specify a task - * {@link protos.google.cloud.tasks.v2beta2.Task.name|name}. If a name is not specified - * then the system will generate a random unique task id, which will be set in - * the task returned in the {@link protos.google.cloud.tasks.v2beta2.Task.name|response}. - * - * If {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} is not - * set or is in the past then Cloud Tasks will set it to the current time. - * - * Task De-duplication: - * - * Explicitly specifying a task ID enables task de-duplication. If - * a task's ID is identical to that of an existing task or a task - * that was deleted or completed recently then the call will fail - * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. - * If the task's queue was created using Cloud Tasks, then another task with - * the same name can't be created for ~1 hour after the original task was - * deleted or completed. If the task's queue was created using queue.yaml or - * queue.xml, then another task with the same name can't be created - * for ~9 days after the original task was deleted or completed. - * - * Because there is an extra lookup cost to identify duplicate task - * names, these {@link protos.google.cloud.tasks.v2beta2.CloudTasks.CreateTask|CreateTask} - * calls have significantly increased latency. Using hashed strings for the - * task id or for the prefix of the task id is recommended. Choosing task ids - * that are sequential or have sequential prefixes, for example using a - * timestamp, causes an increase in latency and error rates in all - * task commands. The infrastructure relies on an approximately - * uniform distribution of task ids to store and serve tasks - * efficiently. - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.create_task.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CreateTask_async - */ + /** + * Creates a task and adds it to a queue. + * + * Tasks cannot be updated after creation; there is no UpdateTask command. + * + * * For {@link protos.google.cloud.tasks.v2beta2.AppEngineHttpTarget|App Engine queues}, + * the maximum task size is + * 100KB. + * * For {@link protos.google.cloud.tasks.v2beta2.PullTarget|pull queues}, the maximum + * task size is 1MB. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * + * The queue must already exist. + * @param {google.cloud.tasks.v2beta2.Task} request.task + * Required. The task to add. + * + * Task names have the following format: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. + * The user can optionally specify a task + * {@link protos.google.cloud.tasks.v2beta2.Task.name|name}. If a name is not specified + * then the system will generate a random unique task id, which will be set in + * the task returned in the {@link protos.google.cloud.tasks.v2beta2.Task.name|response}. + * + * If {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} is not + * set or is in the past then Cloud Tasks will set it to the current time. + * + * Task De-duplication: + * + * Explicitly specifying a task ID enables task de-duplication. If + * a task's ID is identical to that of an existing task or a task + * that was deleted or completed recently then the call will fail + * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. + * If the task's queue was created using Cloud Tasks, then another task with + * the same name can't be created for ~1 hour after the original task was + * deleted or completed. If the task's queue was created using queue.yaml or + * queue.xml, then another task with the same name can't be created + * for ~9 days after the original task was deleted or completed. + * + * Because there is an extra lookup cost to identify duplicate task + * names, these {@link protos.google.cloud.tasks.v2beta2.CloudTasks.CreateTask|CreateTask} + * calls have significantly increased latency. Using hashed strings for the + * task id or for the prefix of the task id is recommended. Choosing task ids + * that are sequential or have sequential prefixes, for example using a + * timestamp, causes an increase in latency and error rates in all + * task commands. The infrastructure relies on an approximately + * uniform distribution of task ids to store and serve tasks + * efficiently. + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.create_task.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CreateTask_async + */ createTask( - request?: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | undefined, + {} | undefined, + ] + >; createTask( - request: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request?: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.ICreateTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.ICreateTaskRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ITask, + | protos.google.cloud.tasks.v2beta2.ICreateTaskRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICreateTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('createTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICreateTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task. - * - * A task can be deleted if it is scheduled or dispatched. A task - * cannot be deleted if it has completed successfully or permanently - * failed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2beta2/cloud_tasks.delete_task.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_async - */ + /** + * Deletes a task. + * + * A task can be deleted if it is scheduled or dispatched. A task + * cannot be deleted if it has completed successfully or permanently + * failed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2beta2/cloud_tasks.delete_task.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_async + */ deleteTask( - request?: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | undefined, + {} | undefined, + ] + >; deleteTask( - request: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request?: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTask request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IDeleteTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Leases tasks from a pull queue for - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration|lease_duration}. - * - * This method is invoked by the worker to obtain a lease. The - * worker must acknowledge the task via - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask|AcknowledgeTask} - * after they have performed the work associated with the task. - * - * The {@link protos.google.cloud.tasks.v2beta2.PullMessage.payload|payload} is intended - * to store data that the worker needs to perform the work associated with the - * task. To return the payloads in the - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response}, set - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.response_view|response_view} - * to {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL}. - * - * A maximum of 10 qps of - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} requests are - * allowed per queue. {@link protos.google.rpc.Code.RESOURCE_EXHAUSTED|RESOURCE_EXHAUSTED} - * is returned when this limit is - * exceeded. {@link protos.google.rpc.Code.RESOURCE_EXHAUSTED|RESOURCE_EXHAUSTED} - * is also returned when - * {@link protos.google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second|max_tasks_dispatched_per_second} - * is exceeded. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {number} request.maxTasks - * The maximum number of tasks to lease. - * - * The system will make a best effort to return as close to as - * `max_tasks` as possible. - * - * The largest that `max_tasks` can be is 1000. - * - * The maximum total size of a [lease tasks - * response][google.cloud.tasks.v2beta2.LeaseTasksResponse] is 32 MB. If the - * sum of all task sizes requested reaches this limit, fewer tasks than - * requested are returned. - * @param {google.protobuf.Duration} request.leaseDuration - * Required. The duration of the lease. - * - * Each task returned in the - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response} will have its - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} set to the - * current time plus the `lease_duration`. The task is leased until its - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}; thus, the - * task will not be returned to another - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} call before - * its {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. - * - * - * After the worker has successfully finished the work associated - * with the task, the worker must call via - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask|AcknowledgeTask} - * before the {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. - * Otherwise the task will be returned to a later - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} call so that - * another worker can retry it. - * - * The maximum lease duration is 1 week. - * `lease_duration` will be truncated to the nearest second. - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. - * @param {string} request.filter - * `filter` can be used to specify a subset of tasks to lease. - * - * When `filter` is set to `tag=` then the - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response} will contain only - * tasks whose {@link protos.google.cloud.tasks.v2beta2.PullMessage.tag|tag} is equal to - * ``. `` must be less than 500 characters. - * - * When `filter` is set to `tag_function=oldest_tag()`, only tasks which have - * the same tag as the task with the oldest - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} will be - * returned. - * - * Grammar Syntax: - * - * * `filter = "tag=" tag | "tag_function=" function` - * - * * `tag = string` - * - * * `function = "oldest_tag()"` - * - * The `oldest_tag()` function returns tasks which have the same tag as the - * oldest task (ordered by schedule time). - * - * SDK compatibility: Although the SDK allows tags to be either - * string or - * [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-), - * only UTF-8 encoded tags can be used in Cloud Tasks. Tag which - * aren't UTF-8 encoded can't be used in the - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.filter|filter} and the - * task's {@link protos.google.cloud.tasks.v2beta2.PullMessage.tag|tag} will be displayed - * as empty in Cloud Tasks. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|LeaseTasksResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.lease_tasks.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_async - */ + /** + * Leases tasks from a pull queue for + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration|lease_duration}. + * + * This method is invoked by the worker to obtain a lease. The + * worker must acknowledge the task via + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask|AcknowledgeTask} + * after they have performed the work associated with the task. + * + * The {@link protos.google.cloud.tasks.v2beta2.PullMessage.payload|payload} is intended + * to store data that the worker needs to perform the work associated with the + * task. To return the payloads in the + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response}, set + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.response_view|response_view} + * to {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL}. + * + * A maximum of 10 qps of + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} requests are + * allowed per queue. {@link protos.google.rpc.Code.RESOURCE_EXHAUSTED|RESOURCE_EXHAUSTED} + * is returned when this limit is + * exceeded. {@link protos.google.rpc.Code.RESOURCE_EXHAUSTED|RESOURCE_EXHAUSTED} + * is also returned when + * {@link protos.google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second|max_tasks_dispatched_per_second} + * is exceeded. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {number} request.maxTasks + * The maximum number of tasks to lease. + * + * The system will make a best effort to return as close to as + * `max_tasks` as possible. + * + * The largest that `max_tasks` can be is 1000. + * + * The maximum total size of a [lease tasks + * response][google.cloud.tasks.v2beta2.LeaseTasksResponse] is 32 MB. If the + * sum of all task sizes requested reaches this limit, fewer tasks than + * requested are returned. + * @param {google.protobuf.Duration} request.leaseDuration + * Required. The duration of the lease. + * + * Each task returned in the + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response} will have its + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} set to the + * current time plus the `lease_duration`. The task is leased until its + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}; thus, the + * task will not be returned to another + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} call before + * its {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. + * + * + * After the worker has successfully finished the work associated + * with the task, the worker must call via + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask|AcknowledgeTask} + * before the {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. + * Otherwise the task will be returned to a later + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} call so that + * another worker can retry it. + * + * The maximum lease duration is 1 week. + * `lease_duration` will be truncated to the nearest second. + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. + * @param {string} request.filter + * `filter` can be used to specify a subset of tasks to lease. + * + * When `filter` is set to `tag=` then the + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|response} will contain only + * tasks whose {@link protos.google.cloud.tasks.v2beta2.PullMessage.tag|tag} is equal to + * ``. `` must be less than 500 characters. + * + * When `filter` is set to `tag_function=oldest_tag()`, only tasks which have + * the same tag as the task with the oldest + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} will be + * returned. + * + * Grammar Syntax: + * + * * `filter = "tag=" tag | "tag_function=" function` + * + * * `tag = string` + * + * * `function = "oldest_tag()"` + * + * The `oldest_tag()` function returns tasks which have the same tag as the + * oldest task (ordered by schedule time). + * + * SDK compatibility: Although the SDK allows tags to be either + * string or + * [bytes](https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/taskqueue/TaskOptions.html#tag-byte:A-), + * only UTF-8 encoded tags can be used in Cloud Tasks. Tag which + * aren't UTF-8 encoded can't be used in the + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.filter|filter} and the + * task's {@link protos.google.cloud.tasks.v2beta2.PullMessage.tag|tag} will be displayed + * as empty in Cloud Tasks. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta2.LeaseTasksResponse|LeaseTasksResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.lease_tasks.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_async + */ leaseTasks( - request?: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | undefined, + {} | undefined, + ] + >; leaseTasks( - request: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | null | undefined, + {} | null | undefined + >, + ): void; leaseTasks( - request: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | null | undefined, + {} | null | undefined + >, + ): void; leaseTasks( - request?: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('leaseTasks request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + | protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('leaseTasks response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.leaseTasks(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, - protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest|undefined, {}|undefined - ]) => { - this._log.info('leaseTasks response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .leaseTasks(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse, + protos.google.cloud.tasks.v2beta2.ILeaseTasksRequest | undefined, + {} | undefined, + ]) => { + this._log.info('leaseTasks response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Acknowledges a pull task. - * - * The worker, that is, the entity that - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|leased} this task must - * call this method to indicate that the work associated with the task has - * finished. - * - * The worker must acknowledge a task within the - * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration|lease_duration} - * or the lease will expire and the task will become available to be leased - * again. After the task is acknowledged, it will not be returned - * by a later {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks}, - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.GetTask|GetTask}, or - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.protobuf.Timestamp} request.scheduleTime - * Required. The task's current schedule time, available in the - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. - * This restriction is to ensure that your worker currently holds the lease. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v2beta2/cloud_tasks.acknowledge_task.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_async - */ + /** + * Acknowledges a pull task. + * + * The worker, that is, the entity that + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|leased} this task must + * call this method to indicate that the work associated with the task has + * finished. + * + * The worker must acknowledge a task within the + * {@link protos.google.cloud.tasks.v2beta2.LeaseTasksRequest.lease_duration|lease_duration} + * or the lease will expire and the task will become available to be leased + * again. After the task is acknowledged, it will not be returned + * by a later {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks}, + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.GetTask|GetTask}, or + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.protobuf.Timestamp} request.scheduleTime + * Required. The task's current schedule time, available in the + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. + * This restriction is to ensure that your worker currently holds the lease. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for 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/v2beta2/cloud_tasks.acknowledge_task.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_async + */ acknowledgeTask( - request?: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest | undefined, + {} | undefined, + ] + >; acknowledgeTask( - request: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acknowledgeTask( - request: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest + | null + | undefined, + {} | null | undefined + >, + ): void; acknowledgeTask( - request?: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest + | null + | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('acknowledgeTask request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('acknowledgeTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.acknowledgeTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('acknowledgeTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .acknowledgeTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta2.IAcknowledgeTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('acknowledgeTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Renew the current lease of a pull task. - * - * The worker can use this method to extend the lease by a new - * duration, starting from now. The new task lease will be - * returned in the task's - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.protobuf.Timestamp} request.scheduleTime - * Required. The task's current schedule time, available in the - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. - * This restriction is to ensure that your worker currently holds the lease. - * @param {google.protobuf.Duration} request.leaseDuration - * Required. The desired new lease duration, starting from now. - * - * - * The maximum lease duration is 1 week. - * `lease_duration` will be truncated to the nearest second. - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.renew_lease.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_RenewLease_async - */ + /** + * Renew the current lease of a pull task. + * + * The worker can use this method to extend the lease by a new + * duration, starting from now. The new task lease will be + * returned in the task's + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.protobuf.Timestamp} request.scheduleTime + * Required. The task's current schedule time, available in the + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. + * This restriction is to ensure that your worker currently holds the lease. + * @param {google.protobuf.Duration} request.leaseDuration + * Required. The desired new lease duration, starting from now. + * + * + * The maximum lease duration is 1 week. + * `lease_duration` will be truncated to the nearest second. + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.renew_lease.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_RenewLease_async + */ renewLease( - request?: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | undefined, + {} | undefined, + ] + >; renewLease( - request: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | null | undefined, + {} | null | undefined + >, + ): void; renewLease( - request: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | null | undefined, + {} | null | undefined + >, + ): void; renewLease( - request?: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('renewLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ITask, + | protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('renewLease response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.renewLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest|undefined, {}|undefined - ]) => { - this._log.info('renewLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .renewLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRenewLeaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('renewLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Cancel a pull task's lease. - * - * The worker can use this method to cancel a task's lease by - * setting its {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} - * to now. This will make the task available to be leased to the next caller - * of {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.protobuf.Timestamp} request.scheduleTime - * Required. The task's current schedule time, available in the - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. - * This restriction is to ensure that your worker currently holds the lease. - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.cancel_lease.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CancelLease_async - */ + /** + * Cancel a pull task's lease. + * + * The worker can use this method to cancel a task's lease by + * setting its {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} + * to now. This will make the task available to be leased to the next caller + * of {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.protobuf.Timestamp} request.scheduleTime + * Required. The task's current schedule time, available in the + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} returned by + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks|LeaseTasks} response or + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RenewLease|RenewLease} response. + * This restriction is to ensure that your worker currently holds the lease. + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.cancel_lease.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_CancelLease_async + */ cancelLease( - request?: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | undefined, + {} | undefined, + ] + >; cancelLease( - request: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | null | undefined, + {} | null | undefined + >, + ): void; cancelLease( - request: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | null | undefined, + {} | null | undefined + >, + ): void; cancelLease( - request?: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('cancelLease request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ITask, + | protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('cancelLease response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.cancelLease(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest|undefined, {}|undefined - ]) => { - this._log.info('cancelLease response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .cancelLease(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.ICancelLeaseRequest | undefined, + {} | undefined, + ]) => { + this._log.info('cancelLease response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Forces a task to run now. - * - * When this method is called, Cloud Tasks will dispatch the task, even if - * the task is already running, the queue has reached its - * {@link protos.google.cloud.tasks.v2beta2.RateLimits|RateLimits} or is - * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED}. - * - * This command is meant to be used for manual debugging. For - * example, {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} can be - * used to retry a failed task after a fix has been made or to manually force - * a task to be dispatched now. - * - * The dispatched task is returned. That is, the task that is returned - * contains the {@link protos.google.cloud.tasks.v2beta2.Task.status|status} after the - * task is dispatched but before the task is received by its target. - * - * If Cloud Tasks receives a successful response from the task's - * target, then the task will be deleted; otherwise the task's - * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} will be - * reset to the time that - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} was called plus - * the retry delay specified in the queue's - * {@link protos.google.cloud.tasks.v2beta2.RetryConfig|RetryConfig}. - * - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} returns - * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a - * task that has already succeeded or permanently failed. - * - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} cannot be called - * on a {@link protos.google.cloud.tasks.v2beta2.PullMessage|pull task}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta2/cloud_tasks.run_task.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_RunTask_async - */ + /** + * Forces a task to run now. + * + * When this method is called, Cloud Tasks will dispatch the task, even if + * the task is already running, the queue has reached its + * {@link protos.google.cloud.tasks.v2beta2.RateLimits|RateLimits} or is + * {@link protos.google.cloud.tasks.v2beta2.Queue.State.PAUSED|PAUSED}. + * + * This command is meant to be used for manual debugging. For + * example, {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} can be + * used to retry a failed task after a fix has been made or to manually force + * a task to be dispatched now. + * + * The dispatched task is returned. That is, the task that is returned + * contains the {@link protos.google.cloud.tasks.v2beta2.Task.status|status} after the + * task is dispatched but before the task is received by its target. + * + * If Cloud Tasks receives a successful response from the task's + * target, then the task will be deleted; otherwise the task's + * {@link protos.google.cloud.tasks.v2beta2.Task.schedule_time|schedule_time} will be + * reset to the time that + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} was called plus + * the retry delay specified in the queue's + * {@link protos.google.cloud.tasks.v2beta2.RetryConfig|RetryConfig}. + * + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} returns + * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a + * task that has already succeeded or permanently failed. + * + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.RunTask|RunTask} cannot be called + * on a {@link protos.google.cloud.tasks.v2beta2.PullMessage|pull task}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} 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.tasks.v2beta2.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta2/cloud_tasks.run_task.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_RunTask_async + */ runTask( - request?: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | undefined, + {} | undefined, + ] + >; runTask( - request: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request?: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta2.IRunTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('runTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('runTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.runTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta2.ITask, - protos.google.cloud.tasks.v2beta2.IRunTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('runTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .runTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta2.ITask, + protos.google.cloud.tasks.v2beta2.IRunTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('runTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queues. - * - * Queues are returned in lexicographical order. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "app_engine_http_target: *". - * - * Note that using filters might cause fewer queues than the - * requested_page size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta2.Queue|Queue}. - * 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 queues. + * + * Queues are returned in lexicographical order. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "app_engine_http_target: *". + * + * Note that using filters might cause fewer queues than the + * requested_page size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta2.Queue|Queue}. + * 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueues( - request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue[], - protos.google.cloud.tasks.v2beta2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse - ]>; + request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue[], + protos.google.cloud.tasks.v2beta2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse, + ] + >; listQueues( - request: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.IQueue>): void; + request: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.IQueue + >, + ): void; listQueues( - request: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.IQueue>): void; + request: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.IQueue + >, + ): void; listQueues( - request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.IQueue>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.IQueue>): - Promise<[ - protos.google.cloud.tasks.v2beta2.IQueue[], - protos.google.cloud.tasks.v2beta2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse - ]>|void { + | protos.google.cloud.tasks.v2beta2.IListQueuesResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta2.IQueue + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.IQueue + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.IQueue[], + protos.google.cloud.tasks.v2beta2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2beta2.IListQueuesRequest, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.IQueue>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + | protos.google.cloud.tasks.v2beta2.IListQueuesResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta2.IQueue + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listQueues values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -2715,291 +3461,314 @@ export class CloudTasksClient { this._log.info('listQueues request %j', request); return this.innerApiCalls .listQueues(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2beta2.IQueue[], - protos.google.cloud.tasks.v2beta2.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta2.IListQueuesResponse - ]) => { - this._log.info('listQueues values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2beta2.IQueue[], + protos.google.cloud.tasks.v2beta2.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta2.IListQueuesResponse, + ]) => { + this._log.info('listQueues values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listQueues`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "app_engine_http_target: *". - * - * Note that using filters might cause fewer queues than the - * requested_page size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @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.tasks.v2beta2.Queue|Queue} 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 `listQueues`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "app_engine_http_target: *". + * + * Note that using filters might cause fewer queues than the + * requested_page size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @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.tasks.v2beta2.Queue|Queue} 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueuesStream( - request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues stream %j', request); return this.descriptors.page.listQueues.createStream( this.innerApiCalls.listQueues as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listQueues`, 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 name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "app_engine_http_target: *". - * - * Note that using filters might cause fewer queues than the - * requested_page size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @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.tasks.v2beta2.Queue|Queue}. 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/v2beta2/cloud_tasks.list_queues.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ListQueues_async - */ + /** + * Equivalent to `listQueues`, 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 name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta2.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "app_engine_http_target: *". + * + * Note that using filters might cause fewer queues than the + * requested_page size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta2.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @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.tasks.v2beta2.Queue|Queue}. 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/v2beta2/cloud_tasks.list_queues.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ListQueues_async + */ listQueuesAsync( - request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2beta2.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues iterate %j', request); return this.descriptors.page.listQueues.asyncIterate( this.innerApiCalls['listQueues'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the tasks in a queue. - * - * By default, only the {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC} - * view is retrieved due to performance considerations; - * {@link protos.google.cloud.tasks.v2beta2.ListTasksRequest.response_view|response_view} - * controls the subset of information which is returned. - * - * The tasks may be returned in any order. The ordering may change at any - * time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta2.Task|Task}. - * 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 tasks in a queue. + * + * By default, only the {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC} + * view is retrieved due to performance considerations; + * {@link protos.google.cloud.tasks.v2beta2.ListTasksRequest.response_view|response_view} + * controls the subset of information which is returned. + * + * The tasks may be returned in any order. The ordering may change at any + * time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta2.Task|Task}. + * 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasks( - request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask[], - protos.google.cloud.tasks.v2beta2.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta2.IListTasksResponse - ]>; + request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask[], + protos.google.cloud.tasks.v2beta2.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta2.IListTasksResponse, + ] + >; listTasks( - request: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListTasksRequest, - protos.google.cloud.tasks.v2beta2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.ITask>): void; + request: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListTasksRequest, + protos.google.cloud.tasks.v2beta2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.ITask + >, + ): void; listTasks( - request: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListTasksRequest, - protos.google.cloud.tasks.v2beta2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.ITask>): void; + request: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListTasksRequest, + protos.google.cloud.tasks.v2beta2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.ITask + >, + ): void; listTasks( - request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2beta2.IListTasksRequest, - protos.google.cloud.tasks.v2beta2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.ITask>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2beta2.IListTasksRequest, - protos.google.cloud.tasks.v2beta2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.ITask>): - Promise<[ - protos.google.cloud.tasks.v2beta2.ITask[], - protos.google.cloud.tasks.v2beta2.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta2.IListTasksResponse - ]>|void { + | protos.google.cloud.tasks.v2beta2.IListTasksResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta2.ITask + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListTasksRequest, + protos.google.cloud.tasks.v2beta2.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta2.ITask + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta2.ITask[], + protos.google.cloud.tasks.v2beta2.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta2.IListTasksResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2beta2.IListTasksRequest, - protos.google.cloud.tasks.v2beta2.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta2.ITask>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2beta2.IListTasksRequest, + | protos.google.cloud.tasks.v2beta2.IListTasksResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta2.ITask + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTasks values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -3008,169 +3777,174 @@ export class CloudTasksClient { this._log.info('listTasks request %j', request); return this.innerApiCalls .listTasks(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2beta2.ITask[], - protos.google.cloud.tasks.v2beta2.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta2.IListTasksResponse - ]) => { - this._log.info('listTasks values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2beta2.ITask[], + protos.google.cloud.tasks.v2beta2.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta2.IListTasksResponse, + ]) => { + this._log.info('listTasks values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTasks`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2beta2.Task|Task} 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 `listTasks`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2beta2.Task|Task} 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasksStream( - request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks stream %j', request); return this.descriptors.page.listTasks.createStream( this.innerApiCalls.listTasks as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTasks`, 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 queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2beta2.Task|Task}. 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/v2beta2/cloud_tasks.list_tasks.js - * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ListTasks_async - */ + /** + * Equivalent to `listTasks`, 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 queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta2.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta2.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta2.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta2.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta2.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta2.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2beta2.Task|Task}. 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/v2beta2/cloud_tasks.list_tasks.js + * region_tag:cloudtasks_v2beta2_generated_CloudTasks_ListTasks_async + */ listTasksAsync( - request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2beta2.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks iterate %j', request); return this.descriptors.page.listTasks.asyncIterate( this.innerApiCalls['listTasks'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -3205,12 +3979,11 @@ export class CloudTasksClient { | 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. @@ -3243,7 +4016,7 @@ export class CloudTasksClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -3259,7 +4032,7 @@ export class CloudTasksClient { * @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, @@ -3294,7 +4067,7 @@ export class CloudTasksClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3319,7 +4092,7 @@ export class CloudTasksClient { * @param {string} queue * @returns {string} Resource name string. */ - queuePath(project:string,location:string,queue:string) { + queuePath(project: string, location: string, queue: string) { return this.pathTemplates.queuePathTemplate.render({ project: project, location: location, @@ -3369,7 +4142,7 @@ export class CloudTasksClient { * @param {string} task * @returns {string} Resource name string. */ - taskPath(project:string,location:string,queue:string,task:string) { + taskPath(project: string, location: string, queue: string, task: string) { return this.pathTemplates.taskPathTemplate.render({ project: project, location: location, @@ -3430,13 +4203,15 @@ export class CloudTasksClient { */ close(): Promise { if (this.cloudTasksStub && !this._terminated) { - return this.cloudTasksStub.then(stub => { + return this.cloudTasksStub.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-tasks/esm/src/v2beta2/index.ts b/packages/google-cloud-tasks/esm/src/v2beta2/index.ts index 9500073e7175..90d3c82528c5 100644 --- a/packages/google-cloud-tasks/esm/src/v2beta2/index.ts +++ b/packages/google-cloud-tasks/esm/src/v2beta2/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudTasksClient} from './cloud_tasks_client.js'; +export { CloudTasksClient } from './cloud_tasks_client.js'; diff --git a/packages/google-cloud-tasks/esm/src/v2beta3/cloud_tasks_client.ts b/packages/google-cloud-tasks/esm/src/v2beta3/cloud_tasks_client.ts index 0ede1ebe850d..3afbd8fe2d73 100644 --- a/packages/google-cloud-tasks/esm/src/v2beta3/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/esm/src/v2beta3/cloud_tasks_client.ts @@ -18,15 +18,24 @@ /* global window */ import * 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'; // @ts-ignore import type * as protos from '../../../protos/protos.js'; import * as cloud_tasks_client_config from './cloud_tasks_client_config.json'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; -import {getJSON} from '../json-helper.cjs'; +import { fileURLToPath } from 'url'; +import { getJSON } from '../json-helper.cjs'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -36,15 +45,15 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); * This file defines retry strategy and timeouts for all API methods in this library. */ const gapicConfig = getJSON( - path.join(dirname, 'cloud_tasks_client_config.json') + path.join(dirname, 'cloud_tasks_client_config.json'), ); const jsonProtos = getJSON( - path.join(dirname, '..', '..', '..', 'protos/protos.json') + path.join(dirname, '..', '..', '..', 'protos/protos.json'), ); -import {loggingUtils as logging, decodeAnyProtosInArray} from 'google-gax'; +import { loggingUtils as logging, decodeAnyProtosInArray } from 'google-gax'; const version = getJSON( - path.join(dirname, '..', '..', '..', '..', 'package.json') + path.join(dirname, '..', '..', '..', '..', 'package.json'), ).version; /** @@ -60,7 +69,7 @@ export class CloudTasksClient { 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('tasks'); @@ -72,10 +81,10 @@ export class CloudTasksClient { batching: {}, }; warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; + innerApiCalls: { [name: string]: Function }; locationsClient: LocationsClient; - pathTemplates: {[name: string]: gax.PathTemplate}; - cloudTasksStub?: Promise<{[name: string]: Function}>; + pathTemplates: { [name: string]: gax.PathTemplate }; + cloudTasksStub?: Promise<{ [name: string]: Function }>; /** * Construct an instance of CloudTasksClient. @@ -117,21 +126,42 @@ export class CloudTasksClient { * const client = new CloudTasksClient({fallback: 'rest'}, 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 CloudTasksClient; - 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 = 'cloudtasks.' + 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; @@ -156,7 +186,7 @@ export class CloudTasksClient { 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; @@ -170,18 +200,14 @@ export class CloudTasksClient { } this.locationsClient = new this._gaxModule.LocationsClient( this._gaxGrpc, - opts + opts, ); - // Add ESM headers const isEsm = true; const isEsmString = isEsm ? '-esm' : '-cjs'; // 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}${isEsmString}`); } else { @@ -189,7 +215,7 @@ export class CloudTasksClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { + } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -197,23 +223,25 @@ export class CloudTasksClient { } // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos as gax.protobuf.INamespace); + this._protos = this._gaxGrpc.loadProtoJSON( + jsonProtos as gax.protobuf.INamespace, + ); // This API contains "path templates"; forward-slash-separated // identifiers to uniquely identify resources within the API. // Create useful helper objects for these. this.pathTemplates = { locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' + 'projects/{project}/locations/{location}', ), projectPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}' + 'projects/{project}', ), queuePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}' + 'projects/{project}/locations/{location}/queues/{queue}', ), taskPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}' + 'projects/{project}/locations/{location}/queues/{queue}/tasks/{task}', ), }; @@ -221,16 +249,25 @@ export class CloudTasksClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listQueues: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'queues'), - listTasks: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tasks') + listQueues: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'queues', + ), + listTasks: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tasks', + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.tasks.v2beta3.CloudTasks', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.cloud.tasks.v2beta3.CloudTasks', + 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 @@ -261,37 +298,57 @@ export class CloudTasksClient { // Put together the "service stub" for // google.cloud.tasks.v2beta3.CloudTasks. this.cloudTasksStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.tasks.v2beta3.CloudTasks') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.cloud.tasks.v2beta3.CloudTasks', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2beta3.CloudTasks, - 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 cloudTasksStubMethods = - ['listQueues', 'getQueue', 'createQueue', 'updateQueue', 'deleteQueue', 'purgeQueue', 'pauseQueue', 'resumeQueue', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions', 'listTasks', 'getTask', 'createTask', 'deleteTask', 'runTask']; + const cloudTasksStubMethods = [ + 'listQueues', + 'getQueue', + 'createQueue', + 'updateQueue', + 'deleteQueue', + 'purgeQueue', + 'pauseQueue', + 'resumeQueue', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + 'listTasks', + 'getTask', + 'createTask', + 'deleteTask', + 'runTask', + ]; for (const methodName of cloudTasksStubMethods) { const callPromise = this.cloudTasksStub.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; @@ -306,8 +363,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -319,8 +382,14 @@ export class CloudTasksClient { * @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 'cloudtasks.googleapis.com'; } @@ -351,9 +420,7 @@ export class CloudTasksClient { * @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; @@ -362,8 +429,9 @@ export class CloudTasksClient { * 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; @@ -374,1682 +442,2167 @@ export class CloudTasksClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets a queue. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The resource name of the queue. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.get_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetQueue_async - */ + /** + * Gets a queue. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The resource name of the queue. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.get_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetQueue_async + */ getQueue( - request?: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | undefined, + {} | undefined, + ] + >; getQueue( - request: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; getQueue( - request?: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IGetQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IGetQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('getQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IGetQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name in which the queue will be created. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * - * The list of allowed locations can be obtained by calling Cloud - * Tasks' implementation of - * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. - * @param {google.cloud.tasks.v2beta3.Queue} request.queue - * Required. The queue to create. - * - * {@link protos.google.cloud.tasks.v2beta3.Queue.name|Queue's name} cannot be the same as - * an existing queue. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.create_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_async - */ + /** + * Creates a queue. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name in which the queue will be created. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * + * The list of allowed locations can be obtained by calling Cloud + * Tasks' implementation of + * {@link protos.google.cloud.location.Locations.ListLocations|ListLocations}. + * @param {google.cloud.tasks.v2beta3.Queue} request.queue + * Required. The queue to create. + * + * {@link protos.google.cloud.tasks.v2beta3.Queue.name|Queue's name} cannot be the same as + * an existing queue. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.create_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_async + */ createQueue( - request?: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | undefined, + {} | undefined, + ] + >; createQueue( - request: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; createQueue( - request?: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.ICreateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.ICreateQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + | protos.google.cloud.tasks.v2beta3.ICreateQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.ICreateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('createQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.ICreateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a queue. - * - * This method creates the queue if it does not exist and updates - * the queue if it does exist. - * - * Queues created with this method allow tasks to live for a maximum of 31 - * days. After a task is 31 days old, the task will be deleted regardless of - * whether it was dispatched or not. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.tasks.v2beta3.Queue} request.queue - * Required. The queue to create or update. - * - * The queue's {@link protos.google.cloud.tasks.v2beta3.Queue.name|name} must be - * specified. - * - * Output only fields cannot be modified using UpdateQueue. - * Any value specified for an output only field will be ignored. - * The queue's {@link protos.google.cloud.tasks.v2beta3.Queue.name|name} cannot be - * changed. - * @param {google.protobuf.FieldMask} request.updateMask - * A mask used to specify which fields of the queue are being updated. - * - * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.update_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_async - */ + /** + * Updates a queue. + * + * This method creates the queue if it does not exist and updates + * the queue if it does exist. + * + * Queues created with this method allow tasks to live for a maximum of 31 + * days. After a task is 31 days old, the task will be deleted regardless of + * whether it was dispatched or not. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.tasks.v2beta3.Queue} request.queue + * Required. The queue to create or update. + * + * The queue's {@link protos.google.cloud.tasks.v2beta3.Queue.name|name} must be + * specified. + * + * Output only fields cannot be modified using UpdateQueue. + * Any value specified for an output only field will be ignored. + * The queue's {@link protos.google.cloud.tasks.v2beta3.Queue.name|name} cannot be + * changed. + * @param {google.protobuf.FieldMask} request.updateMask + * A mask used to specify which fields of the queue are being updated. + * + * If empty, then all fields will 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 {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.update_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_async + */ updateQueue( - request?: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | undefined, + {} | undefined, + ] + >; updateQueue( - request: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; updateQueue( - request?: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'queue.name': request.queue!.name ?? '', + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + 'queue.name': request.queue!.name ?? '', + }); + this.initialize().catch((err) => { + throw err; }); - this.initialize().catch(err => {throw err}); this._log.info('updateQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + | protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('updateQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.updateQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('updateQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .updateQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IUpdateQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('updateQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queue. - * - * This command will delete the queue even if it has tasks in it. - * - * Note: If you delete a queue, a queue with the same name can't be created - * for 7 days. - * - * WARNING: Using this method may have unintended side effects if you are - * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. - * Read - * [Overview of Queue Management and - * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using - * this method. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2beta3/cloud_tasks.delete_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_async - */ + /** + * Deletes a queue. + * + * This command will delete the queue even if it has tasks in it. + * + * Note: If you delete a queue, a queue with the same name can't be created + * for 7 days. + * + * WARNING: Using this method may have unintended side effects if you are + * using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + * Read + * [Overview of Queue Management and + * queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) before using + * this method. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_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.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/v2beta3/cloud_tasks.delete_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_async + */ deleteQueue( - request?: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | undefined, + {} | undefined, + ] + >; deleteQueue( - request: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteQueue( - request?: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteQueue request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Purges a queue by deleting all of its tasks. - * - * All tasks created before this method is called are permanently deleted. - * - * Purge operations can take up to one minute to take effect. Tasks - * might be dispatched before the purge takes effect. A purge is irreversible. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.purge_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_async - */ + /** + * Purges a queue by deleting all of its tasks. + * + * All tasks created before this method is called are permanently deleted. + * + * Purge operations can take up to one minute to take effect. Tasks + * might be dispatched before the purge takes effect. A purge is irreversible. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.purge_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_async + */ purgeQueue( - request?: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | undefined, + {} | undefined, + ] + >; purgeQueue( - request: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; purgeQueue( - request?: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('purgeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + | protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('purgeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.purgeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('purgeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .purgeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPurgeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('purgeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Pauses the queue. - * - * If a queue is paused then the system will stop dispatching tasks - * until the queue is resumed via - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can - * still be added when the queue is paused. A queue is paused if its - * {@link protos.google.cloud.tasks.v2beta3.Queue.state|state} is - * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED}. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.pause_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_async - */ + /** + * Pauses the queue. + * + * If a queue is paused then the system will stop dispatching tasks + * until the queue is resumed via + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue|ResumeQueue}. Tasks can + * still be added when the queue is paused. A queue is paused if its + * {@link protos.google.cloud.tasks.v2beta3.Queue.state|state} is + * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED}. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.pause_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_async + */ pauseQueue( - request?: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | undefined, + {} | undefined, + ] + >; pauseQueue( - request: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; pauseQueue( - request?: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IPauseQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IPauseQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('pauseQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + | protos.google.cloud.tasks.v2beta3.IPauseQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('pauseQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.pauseQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IPauseQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('pauseQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .pauseQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IPauseQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('pauseQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Resume a queue. - * - * This method resumes a queue after it has been - * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED} or - * {@link protos.google.cloud.tasks.v2beta3.Queue.State.DISABLED|DISABLED}. The state of a - * queue is stored in the queue's - * {@link protos.google.cloud.tasks.v2beta3.Queue.state|state}; after calling this method - * it will be set to - * {@link protos.google.cloud.tasks.v2beta3.Queue.State.RUNNING|RUNNING}. - * - * WARNING: Resuming many high-QPS queues at the same time can - * lead to target overloading. If you are resuming high-QPS - * queues, follow the 500/50/5 pattern described in - * [Managing Cloud Tasks Scaling - * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The queue name. For example: - * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.resume_queue.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_async - */ + /** + * Resume a queue. + * + * This method resumes a queue after it has been + * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED} or + * {@link protos.google.cloud.tasks.v2beta3.Queue.State.DISABLED|DISABLED}. The state of a + * queue is stored in the queue's + * {@link protos.google.cloud.tasks.v2beta3.Queue.state|state}; after calling this method + * it will be set to + * {@link protos.google.cloud.tasks.v2beta3.Queue.State.RUNNING|RUNNING}. + * + * WARNING: Resuming many high-QPS queues at the same time can + * lead to target overloading. If you are resuming high-QPS + * queues, follow the 500/50/5 pattern described in + * [Managing Cloud Tasks Scaling + * Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The queue name. For example: + * `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_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.tasks.v2beta3.Queue|Queue}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.resume_queue.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_async + */ resumeQueue( - request?: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | undefined, + {} | undefined, + ] + >; resumeQueue( - request: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; resumeQueue( - request: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): void; resumeQueue( - request?: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IResumeQueueRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IResumeQueueRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('resumeQueue request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.IQueue, + | protos.google.cloud.tasks.v2beta3.IResumeQueueRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('resumeQueue response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.resumeQueue(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.IQueue, - protos.google.cloud.tasks.v2beta3.IResumeQueueRequest|undefined, {}|undefined - ]) => { - this._log.info('resumeQueue response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .resumeQueue(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.IQueue, + protos.google.cloud.tasks.v2beta3.IResumeQueueRequest | undefined, + {} | undefined, + ]) => { + this._log.info('resumeQueue response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 access control policy for a - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. Returns an empty policy if the - * resource exists and does not have a policy set. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.getIamPolicy` - * - * @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 {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.get_iam_policy.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async - */ + /** + * Gets the access control policy for a + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. Returns an empty policy if the + * resource exists and does not have a policy set. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.getIamPolicy` + * + * @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 {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.get_iam_policy.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('getIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('getIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Sets the access control policy for a - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. Replaces any existing policy. - * - * Note: The Cloud Console does not check queue-level IAM permissions yet. - * Project-level permissions are required to use the Cloud Console. - * - * Authorization requires the following - * [Google IAM](https://cloud.google.com/iam) permission on the specified - * resource parent: - * - * * `cloudtasks.queues.setIamPolicy` - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.set_iam_policy.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async - */ + /** + * Sets the access control policy for a + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. Replaces any existing policy. + * + * Note: The Cloud Console does not check queue-level IAM permissions yet. + * Project-level permissions are required to use the Cloud Console. + * + * Authorization requires the following + * [Google IAM](https://cloud.google.com/iam) permission on the specified + * resource parent: + * + * * `cloudtasks.queues.setIamPolicy` + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.set_iam_policy.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('setIamPolicy request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('setIamPolicy response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]) => { - this._log.info('setIamPolicy response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .setIamPolicy(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined, + ]) => { + this._log.info('setIamPolicy response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 permissions that a caller has on a - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. If the resource does not exist, - * this will return an empty set of permissions, not a - * {@link protos.google.rpc.Code.NOT_FOUND|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 - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.test_iam_permissions.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async - */ + /** + * Returns permissions that a caller has on a + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue}. If the resource does not exist, + * this will return an empty set of permissions, not a + * {@link protos.google.rpc.Code.NOT_FOUND|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 + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.test_iam_permissions.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('testIamPermissions request %j', request); - const wrappedCallback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('testIamPermissions response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]) => { - this._log.info('testIamPermissions response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .testIamPermissions(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('testIamPermissions response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 a task. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.get_task.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetTask_async - */ + /** + * Gets a task. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.get_task.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_GetTask_async + */ getTask( - request?: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | undefined, + {} | undefined, + ] + >; getTask( - request: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; getTask( - request?: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IGetTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('getTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('getTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.getTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IGetTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('getTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .getTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IGetTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task and adds it to a queue. - * - * Tasks cannot be updated after creation; there is no UpdateTask command. - * - * * The maximum task size is 100KB. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * - * The queue must already exist. - * @param {google.cloud.tasks.v2beta3.Task} request.task - * Required. The task to add. - * - * Task names have the following format: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. - * The user can optionally specify a task - * {@link protos.google.cloud.tasks.v2beta3.Task.name|name}. If a name is not specified - * then the system will generate a random unique task id, which will be set in - * the task returned in the {@link protos.google.cloud.tasks.v2beta3.Task.name|response}. - * - * If {@link protos.google.cloud.tasks.v2beta3.Task.schedule_time|schedule_time} is not - * set or is in the past then Cloud Tasks will set it to the current time. - * - * Task De-duplication: - * - * Explicitly specifying a task ID enables task de-duplication. If - * a task's ID is identical to that of an existing task or a task - * that was deleted or executed recently then the call will fail - * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. - * If the task's queue was created using Cloud Tasks, then another task with - * the same name can't be created for ~1 hour after the original task was - * deleted or executed. If the task's queue was created using queue.yaml or - * queue.xml, then another task with the same name can't be created - * for ~9 days after the original task was deleted or executed. - * - * Because there is an extra lookup cost to identify duplicate task - * names, these {@link protos.google.cloud.tasks.v2beta3.CloudTasks.CreateTask|CreateTask} - * calls have significantly increased latency. Using hashed strings for the - * task id or for the prefix of the task id is recommended. Choosing task ids - * that are sequential or have sequential prefixes, for example using a - * timestamp, causes an increase in latency and error rates in all - * task commands. The infrastructure relies on an approximately - * uniform distribution of task ids to store and serve tasks - * efficiently. - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.create_task.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_CreateTask_async - */ + /** + * Creates a task and adds it to a queue. + * + * Tasks cannot be updated after creation; there is no UpdateTask command. + * + * * The maximum task size is 100KB. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * + * The queue must already exist. + * @param {google.cloud.tasks.v2beta3.Task} request.task + * Required. The task to add. + * + * Task names have the following format: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. + * The user can optionally specify a task + * {@link protos.google.cloud.tasks.v2beta3.Task.name|name}. If a name is not specified + * then the system will generate a random unique task id, which will be set in + * the task returned in the {@link protos.google.cloud.tasks.v2beta3.Task.name|response}. + * + * If {@link protos.google.cloud.tasks.v2beta3.Task.schedule_time|schedule_time} is not + * set or is in the past then Cloud Tasks will set it to the current time. + * + * Task De-duplication: + * + * Explicitly specifying a task ID enables task de-duplication. If + * a task's ID is identical to that of an existing task or a task + * that was deleted or executed recently then the call will fail + * with {@link protos.google.rpc.Code.ALREADY_EXISTS|ALREADY_EXISTS}. + * If the task's queue was created using Cloud Tasks, then another task with + * the same name can't be created for ~1 hour after the original task was + * deleted or executed. If the task's queue was created using queue.yaml or + * queue.xml, then another task with the same name can't be created + * for ~9 days after the original task was deleted or executed. + * + * Because there is an extra lookup cost to identify duplicate task + * names, these {@link protos.google.cloud.tasks.v2beta3.CloudTasks.CreateTask|CreateTask} + * calls have significantly increased latency. Using hashed strings for the + * task id or for the prefix of the task id is recommended. Choosing task ids + * that are sequential or have sequential prefixes, for example using a + * timestamp, causes an increase in latency and error rates in all + * task commands. The infrastructure relies on an approximately + * uniform distribution of task ids to store and serve tasks + * efficiently. + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.create_task.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_CreateTask_async + */ createTask( - request?: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | undefined, + {} | undefined, + ] + >; createTask( - request: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; createTask( - request?: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.ICreateTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.ICreateTaskRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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('createTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.ITask, + | protos.google.cloud.tasks.v2beta3.ICreateTaskRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('createTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.createTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.ICreateTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('createTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .createTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.ICreateTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('createTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 task. - * - * A task can be deleted if it is scheduled or dispatched. A task - * cannot be deleted if it has executed successfully or permanently - * failed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2beta3/cloud_tasks.delete_task.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_async - */ + /** + * Deletes a task. + * + * A task can be deleted if it is scheduled or dispatched. A task + * cannot be deleted if it has executed successfully or permanently + * failed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_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.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/v2beta3/cloud_tasks.delete_task.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_async + */ deleteTask( - request?: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | undefined, + {} | undefined, + ] + >; deleteTask( - request: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; deleteTask( - request?: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|undefined, {}|undefined - ]>|void { + | protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('deleteTask request %j', request); - const wrappedCallback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.protobuf.IEmpty, + | protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('deleteTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.deleteTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.protobuf.IEmpty, - protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('deleteTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .deleteTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.protobuf.IEmpty, + protos.google.cloud.tasks.v2beta3.IDeleteTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('deleteTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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; }); } -/** - * Forces a task to run now. - * - * When this method is called, Cloud Tasks will dispatch the task, even if - * the task is already running, the queue has reached its - * {@link protos.google.cloud.tasks.v2beta3.RateLimits|RateLimits} or is - * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED}. - * - * This command is meant to be used for manual debugging. For - * example, {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} can be - * used to retry a failed task after a fix has been made or to manually force - * a task to be dispatched now. - * - * The dispatched task is returned. That is, the task that is returned - * contains the {@link protos.Task.status|status} after the task is dispatched but - * before the task is received by its target. - * - * If Cloud Tasks receives a successful response from the task's - * target, then the task will be deleted; otherwise the task's - * {@link protos.google.cloud.tasks.v2beta3.Task.schedule_time|schedule_time} will be - * reset to the time that - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} was called plus - * the retry delay specified in the queue's - * {@link protos.google.cloud.tasks.v2beta3.RetryConfig|RetryConfig}. - * - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} returns - * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a - * task that has already succeeded or permanently failed. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The task name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. - * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } - * for more details and examples. - * @example include:samples/generated/v2beta3/cloud_tasks.run_task.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_RunTask_async - */ + /** + * Forces a task to run now. + * + * When this method is called, Cloud Tasks will dispatch the task, even if + * the task is already running, the queue has reached its + * {@link protos.google.cloud.tasks.v2beta3.RateLimits|RateLimits} or is + * {@link protos.google.cloud.tasks.v2beta3.Queue.State.PAUSED|PAUSED}. + * + * This command is meant to be used for manual debugging. For + * example, {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} can be + * used to retry a failed task after a fix has been made or to manually force + * a task to be dispatched now. + * + * The dispatched task is returned. That is, the task that is returned + * contains the {@link protos.Task.status|status} after the task is dispatched but + * before the task is received by its target. + * + * If Cloud Tasks receives a successful response from the task's + * target, then the task will be deleted; otherwise the task's + * {@link protos.google.cloud.tasks.v2beta3.Task.schedule_time|schedule_time} will be + * reset to the time that + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} was called plus + * the retry delay specified in the queue's + * {@link protos.google.cloud.tasks.v2beta3.RetryConfig|RetryConfig}. + * + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.RunTask|RunTask} returns + * {@link protos.google.rpc.Code.NOT_FOUND|NOT_FOUND} when it is called on a + * task that has already succeeded or permanently failed. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The task name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} 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.tasks.v2beta3.Task|Task}. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } + * for more details and examples. + * @example include:samples/generated/v2beta3/cloud_tasks.run_task.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_RunTask_async + */ runTask( - request?: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|undefined, {}|undefined - ]>; + request?: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | undefined, + {} | undefined, + ] + >; runTask( - request: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, - callback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, + callback: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): void; runTask( - request?: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.cloud.tasks.v2beta3.IRunTaskRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|undefined, {}|undefined - ]>|void { + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | undefined, + {} | undefined, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = this._gaxModule.routingHeader.fromParams({ - 'name': request.name ?? '', + options.otherArgs.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('runTask request %j', request); - const wrappedCallback: Callback< - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|null|undefined, - {}|null|undefined>|undefined = callback + const wrappedCallback: + | Callback< + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | null | undefined, + {} | null | undefined + > + | undefined = callback ? (error, response, options, rawResponse) => { this._log.info('runTask response %j', response); callback!(error, response, options, rawResponse); } : undefined; - return this.innerApiCalls.runTask(request, options, wrappedCallback) - ?.then(([response, options, rawResponse]: [ - protos.google.cloud.tasks.v2beta3.ITask, - protos.google.cloud.tasks.v2beta3.IRunTaskRequest|undefined, {}|undefined - ]) => { - this._log.info('runTask response %j', response); - return [response, options, rawResponse]; - }).catch((error: any) => { - if (error && 'statusDetails' in error && 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 + .runTask(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.cloud.tasks.v2beta3.ITask, + protos.google.cloud.tasks.v2beta3.IRunTaskRequest | undefined, + {} | undefined, + ]) => { + this._log.info('runTask response %j', response); + return [response, options, rawResponse]; + }, + ) + .catch((error: any) => { + if ( + error && + 'statusDetails' in error && + 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 queues. - * - * Queues are returned in lexicographical order. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta3.Queue|Queue}. - * 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 queues. + * + * Queues are returned in lexicographical order. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta3.Queue|Queue}. + * 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueues( - request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue[], - protos.google.cloud.tasks.v2beta3.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse - ]>; + request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue[], + protos.google.cloud.tasks.v2beta3.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse, + ] + >; listQueues( - request: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.IQueue>): void; + request: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.IQueue + >, + ): void; listQueues( - request: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.IQueue>): void; + request: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.IQueue + >, + ): void; listQueues( - request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.IQueue>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.IQueue>): - Promise<[ - protos.google.cloud.tasks.v2beta3.IQueue[], - protos.google.cloud.tasks.v2beta3.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse - ]>|void { + | protos.google.cloud.tasks.v2beta3.IListQueuesResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta3.IQueue + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.IQueue + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.IQueue[], + protos.google.cloud.tasks.v2beta3.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2beta3.IListQueuesRequest, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.IQueue>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + | protos.google.cloud.tasks.v2beta3.IListQueuesResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta3.IQueue + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listQueues values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -2058,291 +2611,314 @@ export class CloudTasksClient { this._log.info('listQueues request %j', request); return this.innerApiCalls .listQueues(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2beta3.IQueue[], - protos.google.cloud.tasks.v2beta3.IListQueuesRequest|null, - protos.google.cloud.tasks.v2beta3.IListQueuesResponse - ]) => { - this._log.info('listQueues values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2beta3.IQueue[], + protos.google.cloud.tasks.v2beta3.IListQueuesRequest | null, + protos.google.cloud.tasks.v2beta3.IListQueuesResponse, + ]) => { + this._log.info('listQueues values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listQueues`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The location name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @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.tasks.v2beta3.Queue|Queue} 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 `listQueuesAsync()` - * method described below for async iteration which you can stop as 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 `listQueues`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The location name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @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.tasks.v2beta3.Queue|Queue} 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 `listQueuesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listQueuesStream( - request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues stream %j', request); return this.descriptors.page.listQueues.createStream( this.innerApiCalls.listQueues as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listQueues`, 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 name. - * For example: `projects/PROJECT_ID/locations/LOCATION_ID` - * @param {string} request.filter - * `filter` can be used to specify a subset of queues. Any - * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and - * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The - * filter syntax is the same as described in [Stackdriver's Advanced Logs - * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). - * - * Sample filter "state: PAUSED". - * - * Note that using filters might cause fewer queues than the - * requested page_size to be returned. - * @param {number} request.pageSize - * Requested page size. - * - * The maximum page size is 9800. If unspecified, the page size will - * be the maximum. Fewer queues than requested might be returned, - * even if more queues exist; use the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * in the response to determine if more queues exist. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It - * is an error to switch the value of the - * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while - * iterating through pages. - * @param {google.protobuf.FieldMask} [request.readMask] - * Optional. Read mask is used for a more granular control over what the API - * returns. If the mask is not present all fields will be returned except - * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly - * specified in the mask. - * @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.tasks.v2beta3.Queue|Queue}. 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/v2beta3/cloud_tasks.list_queues.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ListQueues_async - */ + /** + * Equivalent to `listQueues`, 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 name. + * For example: `projects/PROJECT_ID/locations/LOCATION_ID` + * @param {string} request.filter + * `filter` can be used to specify a subset of queues. Any + * {@link protos.google.cloud.tasks.v2beta3.Queue|Queue} field can be used as a filter and + * several operators as supported. For example: `<=, <, >=, >, !=, =, :`. The + * filter syntax is the same as described in [Stackdriver's Advanced Logs + * Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + * + * Sample filter "state: PAUSED". + * + * Note that using filters might cause fewer queues than the + * requested page_size to be returned. + * @param {number} request.pageSize + * Requested page size. + * + * The maximum page size is 9800. If unspecified, the page size will + * be the maximum. Fewer queues than requested might be returned, + * even if more queues exist; use the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * in the response to determine if more queues exist. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListQueues|ListQueues} method. It + * is an error to switch the value of the + * {@link protos.google.cloud.tasks.v2beta3.ListQueuesRequest.filter|filter} while + * iterating through pages. + * @param {google.protobuf.FieldMask} [request.readMask] + * Optional. Read mask is used for a more granular control over what the API + * returns. If the mask is not present all fields will be returned except + * [Queue.stats]. [Queue.stats] will be returned only if it was explicitly + * specified in the mask. + * @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.tasks.v2beta3.Queue|Queue}. 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/v2beta3/cloud_tasks.list_queues.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ListQueues_async + */ listQueuesAsync( - request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2beta3.IListQueuesRequest, + 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['listQueues']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listQueues iterate %j', request); return this.descriptors.page.listQueues.asyncIterate( this.innerApiCalls['listQueues'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } - /** - * Lists the tasks in a queue. - * - * By default, only the {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC} - * view is retrieved due to performance considerations; - * {@link protos.google.cloud.tasks.v2beta3.ListTasksRequest.response_view|response_view} - * controls the subset of information which is returned. - * - * The tasks may be returned in any order. The ordering may change at any - * time. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta3.Task|Task}. - * 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 tasks in a queue. + * + * By default, only the {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC} + * view is retrieved due to performance considerations; + * {@link protos.google.cloud.tasks.v2beta3.ListTasksRequest.response_view|response_view} + * controls the subset of information which is returned. + * + * The tasks may be returned in any order. The ordering may change at any + * time. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/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.tasks.v2beta3.Task|Task}. + * 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasks( - request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask[], - protos.google.cloud.tasks.v2beta3.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta3.IListTasksResponse - ]>; + request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask[], + protos.google.cloud.tasks.v2beta3.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta3.IListTasksResponse, + ] + >; listTasks( - request: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListTasksRequest, - protos.google.cloud.tasks.v2beta3.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.ITask>): void; + request: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListTasksRequest, + protos.google.cloud.tasks.v2beta3.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.ITask + >, + ): void; listTasks( - request: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - callback: PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListTasksRequest, - protos.google.cloud.tasks.v2beta3.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.ITask>): void; + request: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + callback: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListTasksRequest, + protos.google.cloud.tasks.v2beta3.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.ITask + >, + ): void; listTasks( - request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.tasks.v2beta3.IListTasksRequest, - protos.google.cloud.tasks.v2beta3.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.ITask>, - callback?: PaginationCallback< + request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.cloud.tasks.v2beta3.IListTasksRequest, - protos.google.cloud.tasks.v2beta3.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.ITask>): - Promise<[ - protos.google.cloud.tasks.v2beta3.ITask[], - protos.google.cloud.tasks.v2beta3.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta3.IListTasksResponse - ]>|void { + | protos.google.cloud.tasks.v2beta3.IListTasksResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta3.ITask + >, + callback?: PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListTasksRequest, + protos.google.cloud.tasks.v2beta3.IListTasksResponse | null | undefined, + protos.google.cloud.tasks.v2beta3.ITask + >, + ): Promise< + [ + protos.google.cloud.tasks.v2beta3.ITask[], + protos.google.cloud.tasks.v2beta3.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta3.IListTasksResponse, + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as 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.tasks.v2beta3.IListTasksRequest, - protos.google.cloud.tasks.v2beta3.IListTasksResponse|null|undefined, - protos.google.cloud.tasks.v2beta3.ITask>|undefined = callback + const wrappedCallback: + | PaginationCallback< + protos.google.cloud.tasks.v2beta3.IListTasksRequest, + | protos.google.cloud.tasks.v2beta3.IListTasksResponse + | null + | undefined, + protos.google.cloud.tasks.v2beta3.ITask + > + | undefined = callback ? (error, values, nextPageRequest, rawResponse) => { this._log.info('listTasks values %j', values); callback!(error, values, nextPageRequest, rawResponse); @@ -2351,169 +2927,174 @@ export class CloudTasksClient { this._log.info('listTasks request %j', request); return this.innerApiCalls .listTasks(request, options, wrappedCallback) - ?.then(([response, input, output]: [ - protos.google.cloud.tasks.v2beta3.ITask[], - protos.google.cloud.tasks.v2beta3.IListTasksRequest|null, - protos.google.cloud.tasks.v2beta3.IListTasksResponse - ]) => { - this._log.info('listTasks values %j', response); - return [response, input, output]; - }); + ?.then( + ([response, input, output]: [ + protos.google.cloud.tasks.v2beta3.ITask[], + protos.google.cloud.tasks.v2beta3.IListTasksRequest | null, + protos.google.cloud.tasks.v2beta3.IListTasksResponse, + ]) => { + this._log.info('listTasks values %j', response); + return [response, input, output]; + }, + ); } -/** - * Equivalent to `listTasks`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2beta3.Task|Task} 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 `listTasksAsync()` - * method described below for async iteration which you can stop as 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 `listTasks`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2beta3.Task|Task} 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 `listTasksAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination | documentation } + * for more details and examples. + */ listTasksStream( - request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - options?: CallOptions): - Transform{ + request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks stream %j', request); return this.descriptors.page.listTasks.createStream( this.innerApiCalls.listTasks as GaxCall, request, - callSettings + callSettings, ); } -/** - * Equivalent to `listTasks`, 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 queue name. For example: - * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` - * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView - * The response_view specifies which subset of the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. - * - * By default response_view is - * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is - * retrieved by default because some data, such as payloads, might be - * desirable to return only when needed because of its large size or because - * of the sensitivity of data that it contains. - * - * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} - * requires `cloudtasks.tasks.fullView` [Google - * IAM](https://cloud.google.com/iam/) permission on the - * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. - * @param {number} request.pageSize - * Maximum page size. - * - * Fewer tasks than requested might be returned, even if more tasks exist; use - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * in the response to determine if more tasks exist. - * - * The maximum page size is 1000. If unspecified, the page size will be the - * maximum. - * @param {string} request.pageToken - * A token identifying the page of results to return. - * - * To request the first page results, page_token must be empty. To - * request the next page of results, page_token must be the value of - * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} - * returned from the previous call to - * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. - * - * The page token is valid for only 2 hours. - * @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.tasks.v2beta3.Task|Task}. 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/v2beta3/cloud_tasks.list_tasks.js - * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ListTasks_async - */ + /** + * Equivalent to `listTasks`, 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 queue name. For example: + * `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + * @param {google.cloud.tasks.v2beta3.Task.View} request.responseView + * The response_view specifies which subset of the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} will be returned. + * + * By default response_view is + * {@link protos.google.cloud.tasks.v2beta3.Task.View.BASIC|BASIC}; not all information is + * retrieved by default because some data, such as payloads, might be + * desirable to return only when needed because of its large size or because + * of the sensitivity of data that it contains. + * + * Authorization for {@link protos.google.cloud.tasks.v2beta3.Task.View.FULL|FULL} + * requires `cloudtasks.tasks.fullView` [Google + * IAM](https://cloud.google.com/iam/) permission on the + * {@link protos.google.cloud.tasks.v2beta3.Task|Task} resource. + * @param {number} request.pageSize + * Maximum page size. + * + * Fewer tasks than requested might be returned, even if more tasks exist; use + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * in the response to determine if more tasks exist. + * + * The maximum page size is 1000. If unspecified, the page size will be the + * maximum. + * @param {string} request.pageToken + * A token identifying the page of results to return. + * + * To request the first page results, page_token must be empty. To + * request the next page of results, page_token must be the value of + * {@link protos.google.cloud.tasks.v2beta3.ListTasksResponse.next_page_token|next_page_token} + * returned from the previous call to + * {@link protos.google.cloud.tasks.v2beta3.CloudTasks.ListTasks|ListTasks} method. + * + * The page token is valid for only 2 hours. + * @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.tasks.v2beta3.Task|Task}. 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/v2beta3/cloud_tasks.list_tasks.js + * region_tag:cloudtasks_v2beta3_generated_CloudTasks_ListTasks_async + */ listTasksAsync( - request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.cloud.tasks.v2beta3.IListTasksRequest, + 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['listTasks']; const callSettings = defaultCallSettings.merge(options); - this.initialize().catch(err => {throw err}); + this.initialize().catch((err) => { + throw err; + }); this._log.info('listTasks iterate %j', request); return this.descriptors.page.listTasks.asyncIterate( this.innerApiCalls['listTasks'] as GaxCall, request as {}, - callSettings + callSettings, ) as AsyncIterable; } -/** + + /** * Gets information about a location. * * @param {Object} request @@ -2548,12 +3129,11 @@ export class CloudTasksClient { | 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. @@ -2586,7 +3166,7 @@ export class CloudTasksClient { */ listLocationsAsync( request: LocationProtos.google.cloud.location.IListLocationsRequest, - options?: CallOptions + options?: CallOptions, ): AsyncIterable { return this.locationsClient.listLocationsAsync(request, options); } @@ -2602,7 +3182,7 @@ export class CloudTasksClient { * @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, @@ -2637,7 +3217,7 @@ export class CloudTasksClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -2662,7 +3242,7 @@ export class CloudTasksClient { * @param {string} queue * @returns {string} Resource name string. */ - queuePath(project:string,location:string,queue:string) { + queuePath(project: string, location: string, queue: string) { return this.pathTemplates.queuePathTemplate.render({ project: project, location: location, @@ -2712,7 +3292,7 @@ export class CloudTasksClient { * @param {string} task * @returns {string} Resource name string. */ - taskPath(project:string,location:string,queue:string,task:string) { + taskPath(project: string, location: string, queue: string, task: string) { return this.pathTemplates.taskPathTemplate.render({ project: project, location: location, @@ -2773,13 +3353,15 @@ export class CloudTasksClient { */ close(): Promise { if (this.cloudTasksStub && !this._terminated) { - return this.cloudTasksStub.then(stub => { + return this.cloudTasksStub.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-tasks/esm/src/v2beta3/index.ts b/packages/google-cloud-tasks/esm/src/v2beta3/index.ts index 9500073e7175..90d3c82528c5 100644 --- a/packages/google-cloud-tasks/esm/src/v2beta3/index.ts +++ b/packages/google-cloud-tasks/esm/src/v2beta3/index.ts @@ -16,4 +16,4 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -export {CloudTasksClient} from './cloud_tasks_client.js'; +export { CloudTasksClient } from './cloud_tasks_client.js'; diff --git a/packages/google-cloud-tasks/esm/system-test/fixtures/sample/src/index.ts b/packages/google-cloud-tasks/esm/system-test/fixtures/sample/src/index.ts index 89f52e99efca..86f303ed2ab9 100644 --- a/packages/google-cloud-tasks/esm/system-test/fixtures/sample/src/index.ts +++ b/packages/google-cloud-tasks/esm/system-test/fixtures/sample/src/index.ts @@ -17,7 +17,7 @@ // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** -import {CloudTasksClient} from '@google-cloud/tasks'; +import { CloudTasksClient } from '@google-cloud/tasks'; // check that the client class type name can be used function doStuffWithCloudTasksClient(client: CloudTasksClient) { diff --git a/packages/google-cloud-tasks/esm/system-test/install.ts b/packages/google-cloud-tasks/esm/system-test/install.ts index e079c4fa1101..d109fdd8c97f 100644 --- a/packages/google-cloud-tasks/esm/system-test/install.ts +++ b/packages/google-cloud-tasks/esm/system-test/install.ts @@ -16,40 +16,45 @@ // ** 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', async function() { + it('TypeScript', async function () { this.timeout(300000); await packNTest({ packageDir: process.cwd(), sample: { description: 'TypeScript user can use the type definitions', - ts: readFileSync('./esm/system-test/fixtures/sample/src/index.ts').toString() - } + ts: readFileSync( + './esm/system-test/fixtures/sample/src/index.ts', + ).toString(), + }, }); }); - it('ESM module', async function() { + it('ESM module', async function () { this.timeout(300000); await packNTest({ sample: { description: 'Should be able to import using ESM', - esm: readFileSync('./esm/system-test/fixtures/sample/src/index.js').toString(), + esm: readFileSync( + './esm/system-test/fixtures/sample/src/index.js', + ).toString(), }, }); }); - it('CJS module', async function() { + it('CJS module', async function () { this.timeout(300000); await packNTest({ sample: { description: 'Should be able to import using CJS', - cjs: readFileSync('./esm/system-test/fixtures/sample/src/index.cjs').toString(), + cjs: readFileSync( + './esm/system-test/fixtures/sample/src/index.cjs', + ).toString(), }, }); }); - }); diff --git a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2.ts b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2.ts index e1199110b4d6..da7c664e88b7 100644 --- a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2.ts +++ b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2.ts @@ -20,16 +20,16 @@ import * as protos from '../../protos/protos.js'; import 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 cloudtasksModule from '../src/index.js'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LocationProtos} from 'google-gax'; +import { protobuf, LocationProtos } from 'google-gax'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; +import { fileURLToPath } from 'url'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -37,2577 +37,3164 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); // to fill in default values for request objects const root = protobuf.Root.fromJSON( JSON.parse( - fs.readFileSync(path.join(dirname, '..', '..', 'protos/protos.json'), 'utf8') - )) + fs.readFileSync( + path.join(dirname, '..', '..', 'protos/protos.json'), + 'utf8', + ), + ), +); // 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 ?? null; + 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 ?? null; } 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('v2.CloudTasksClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudtasksModule.v2.CloudTasksClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudtasksModule.v2.CloudTasksClient(); - 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 = cloudtasksModule.v2.CloudTasksClient.servicePath; - assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudtasksModule.v2.CloudTasksClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudtasksModule.v2.CloudTasksClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudtasksModule.v2.CloudTasksClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2.CloudTasksClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2.CloudTasksClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2.CloudTasksClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = cloudtasksModule.v2.CloudTasksClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudtasksModule.v2.CloudTasksClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - await client.initialize(); - assert(client.cloudTasksStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudTasksStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); }); - describe('getQueue', () => { - it('invokes getQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); - const [response] = await client.getQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has universeDomain', () => { + const client = new cloudtasksModule.v2.CloudTasksClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('invokes getQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue 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 = cloudtasksModule.v2.CloudTasksClient.servicePath; + assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = cloudtasksModule.v2.CloudTasksClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); + }); - it('invokes getQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getQueue(request), expectedError); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); }); - describe('createQueue', () => { - it('invokes createQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); - const [response] = await client.createQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue 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 cloudtasksModule.v2.CloudTasksClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2.CloudTasksClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2.CloudTasksClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes createQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = cloudtasksModule.v2.CloudTasksClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes createQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue 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 cloudtasksModule.v2.CloudTasksClient(); + assert(client); + }); - it('invokes createQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createQueue(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + fallback: true, + }); + assert(client); }); - describe('updateQueue', () => { - it('invokes updateQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); - const [response] = await client.updateQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + await client.initialize(); + assert(client.cloudTasksStub); + }); - it('invokes updateQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudTasksStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateQueue(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudtasksModule.v2.CloudTasksClient({ + 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('deleteQueue', () => { - it('invokes deleteQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); - const [response] = await client.deleteQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue 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 cloudtasksModule.v2.CloudTasksClient({ + 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('getQueue', () => { + it('invokes getQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); + const [response] = await client.getQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteQueue( - 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.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.getQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteQueue(request), expectedError); - }); + it('invokes getQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getQueue(request), expectedError); + }); + }); + + describe('createQueue', () => { + it('invokes createQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); + const [response] = await client.createQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('purgeQueue', () => { - it('invokes purgeQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.purgeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.createQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.purgeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createQueue(request), expectedError); + }); + }); + + describe('updateQueue', () => { + it('invokes updateQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); + const [response] = await client.updateQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.purgeQueue(request), expectedError); - }); + it('invokes updateQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.updateQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('pauseQueue', () => { - it('invokes pauseQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); - const [response] = await client.pauseQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateQueue(request), expectedError); + }); + }); + + describe('deleteQueue', () => { + it('invokes deleteQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); + const [response] = await client.deleteQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteQueue( + 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.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.pauseQueue(request), expectedError); - }); + it('invokes deleteQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resumeQueue', () => { - it('invokes resumeQueue without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.resumeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteQueue(request), expectedError); + }); + }); + + describe('purgeQueue', () => { + it('invokes purgeQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.purgeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes purgeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.purgeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes purgeQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.purgeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resumeQueue(request), expectedError); - }); + it('invokes purgeQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.purgeQueue(request), expectedError); + }); + }); + + describe('pauseQueue', () => { + it('invokes pauseQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); + const [response] = await client.pauseQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.pauseQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.pauseQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.pauseQueue(request), expectedError); + }); + }); + + describe('resumeQueue', () => { + it('invokes resumeQueue without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.resumeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); + it('invokes resumeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Queue(), + ); + client.innerApiCalls.resumeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resumeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resumeQueue(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); + it('invokes getIamPolicy with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); + it('invokes setIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTask', () => { - it('invokes getTask without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('getTask', () => { + it('invokes getTask without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTask(request), expectedError); - }); + it('invokes getTask without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.getTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTask', () => { - it('invokes createTask without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); - const [response] = await client.createTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.createTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('createTask', () => { + it('invokes createTask without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); + const [response] = await client.createTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTask(request), expectedError); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.createTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTask(request), expectedError); - }); + it('invokes createTask with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTask', () => { - it('invokes deleteTask without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTask(request), expectedError); + }); + }); + + describe('deleteTask', () => { + it('invokes deleteTask without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTask( - 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.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTask( + 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.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTask(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTask(request), expectedError); - }); + it('invokes deleteTask with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTask(request), expectedError); + }); + }); + + describe('runTask', () => { + it('invokes runTask without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); + const [response] = await client.runTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('runTask', () => { - it('invokes runTask without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); - const [response] = await client.runTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2.Task(), + ); + client.innerApiCalls.runTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2.Task() - ); - client.innerApiCalls.runTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runTask(request), expectedError); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runTask(request), expectedError); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with closed client', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.runTask(request), expectedError); + }); + }); + + describe('listQueues', () => { + it('invokes listQueues without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + ]; + client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); + const [response] = await client.listQueues(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with closed client', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.runTask(request), expectedError); - }); + it('invokes listQueues without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + ]; + client.innerApiCalls.listQueues = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listQueues( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.IQueue[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listQueues', () => { - it('invokes listQueues without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); - const [response] = await client.listQueues(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueues with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listQueues = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listQueues(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listQueues without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listQueues( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.IQueue[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + ]; + client.descriptors.page.listQueues.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2.Queue[] = []; + stream.on('data', (response: protos.google.cloud.tasks.v2.Queue) => { + 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.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueues with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listQueues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listQueues(request), expectedError); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2.Queue[] = []; + stream.on('data', (response: protos.google.cloud.tasks.v2.Queue) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - ]; - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2.Queue) => { - 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.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), + ]; + client.descriptors.page.listQueues.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2.IQueue[] = []; + const iterable = client.listQueuesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2.Queue) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listQueuesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2.IQueue[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listQueues without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Queue()), - ]; - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2.IQueue[] = []; - const iterable = client.listQueuesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTasks without error using callback', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + ]; + client.innerApiCalls.listTasks = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2.ITask[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listQueues with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listQueuesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2.IQueue[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.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.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTasks with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTasksStream without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + ]; + client.descriptors.page.listTasks.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2.Task[] = []; + stream.on('data', (response: protos.google.cloud.tasks.v2.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTasksStream with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2.Task[] = []; + stream.on('data', (response: protos.google.cloud.tasks.v2.Task) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks without error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks without error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks with error', async () => { - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks with error', async () => { + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ + 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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ + 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 cloudtasksModule.v2.CloudTasksClient({ - 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 cloudtasksModule.v2.CloudTasksClient({ + 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 cloudtasksModule.v2.CloudTasksClient({ + 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 cloudtasksModule.v2.CloudTasksClient({ + 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('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('queue', () => { - const fakePath = "/rendered/path/queue"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - }; - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.queuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.queuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('queuePath', () => { - const result = client.queuePath("projectValue", "locationValue", "queueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.queuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromQueueName', () => { - const result = client.matchProjectFromQueueName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromQueueName', () => { - const result = client.matchLocationFromQueueName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromQueueName', () => { - const result = client.matchQueueFromQueueName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('queue', () => { + const fakePath = '/rendered/path/queue'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + }; + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.queuePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.queuePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('queuePath', () => { + const result = client.queuePath( + 'projectValue', + 'locationValue', + 'queueValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.queuePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromQueueName', () => { + const result = client.matchProjectFromQueueName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromQueueName', () => { + const result = client.matchLocationFromQueueName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromQueueName', () => { + const result = client.matchQueueFromQueueName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - task: "taskValue", - }; - const client = new cloudtasksModule.v2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "queueValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromTaskName', () => { - const result = client.matchQueueFromTaskName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('task', () => { + const fakePath = '/rendered/path/task'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + task: 'taskValue', + }; + const client = new cloudtasksModule.v2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.taskPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.taskPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath( + 'projectValue', + 'locationValue', + 'queueValue', + 'taskValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromTaskName', () => { + const result = client.matchQueueFromTaskName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, 'taskValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta2.ts b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta2.ts index c7cdb2617c40..f05537982103 100644 --- a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta2.ts +++ b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta2.ts @@ -20,16 +20,16 @@ import * as protos from '../../protos/protos.js'; import 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 cloudtasksModule from '../src/index.js'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LocationProtos} from 'google-gax'; +import { protobuf, LocationProtos } from 'google-gax'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; +import { fileURLToPath } from 'url'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -37,3084 +37,3791 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); // to fill in default values for request objects const root = protobuf.Root.fromJSON( JSON.parse( - fs.readFileSync(path.join(dirname, '..', '..', 'protos/protos.json'), 'utf8') - )) + fs.readFileSync( + path.join(dirname, '..', '..', 'protos/protos.json'), + 'utf8', + ), + ), +); // 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 ?? null; + 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 ?? null; } 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('v2beta2.CloudTasksClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient(); - 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 = cloudtasksModule.v2beta2.CloudTasksClient.servicePath; - assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudtasksModule.v2beta2.CloudTasksClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta2.CloudTasksClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta2.CloudTasksClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta2.CloudTasksClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = cloudtasksModule.v2beta2.CloudTasksClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - await client.initialize(); - assert(client.cloudTasksStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudTasksStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); }); - describe('getQueue', () => { - it('invokes getQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); - const [response] = await client.getQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getQueue(request), expectedError); - }); + it('has universeDomain', () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); }); - describe('createQueue', () => { - it('invokes createQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); - const [response] = await client.createQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes createQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createQueue(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 = + cloudtasksModule.v2beta2.CloudTasksClient.servicePath; + assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudtasksModule.v2beta2.CloudTasksClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); }); - describe('updateQueue', () => { - it('invokes updateQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); - const [response] = await client.updateQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); + }); - it('invokes updateQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2beta2.CloudTasksClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta2.CloudTasksClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta2.CloudTasksClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes updateQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = cloudtasksModule.v2beta2.CloudTasksClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes updateQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateQueue(request), expectedError); - }); + it('should create a client with no option', () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient(); + assert(client); }); - describe('deleteQueue', () => { - it('invokes deleteQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); - const [response] = await client.deleteQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + fallback: true, + }); + assert(client); + }); - it('invokes deleteQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteQueue( - 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.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + await client.initialize(); + assert(client.cloudTasksStub); + }); - it('invokes deleteQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudTasksStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes deleteQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteQueue(request), expectedError); + it('has close method for the non-initialized client', (done) => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); }); - describe('purgeQueue', () => { - it('invokes purgeQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.purgeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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 purgeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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('getQueue', () => { + it('invokes getQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); + const [response] = await client.getQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.purgeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.getQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.purgeQueue(request), expectedError); - }); + it('invokes getQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('pauseQueue', () => { - it('invokes pauseQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); - const [response] = await client.pauseQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getQueue(request), expectedError); + }); + }); + + describe('createQueue', () => { + it('invokes createQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); + const [response] = await client.createQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.createQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.pauseQueue(request), expectedError); - }); + it('invokes createQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createQueue(request), expectedError); + }); + }); + + describe('updateQueue', () => { + it('invokes updateQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); + const [response] = await client.updateQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resumeQueue', () => { - it('invokes resumeQueue without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.resumeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.updateQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateQueue(request), expectedError); + }); + }); + + describe('deleteQueue', () => { + it('invokes deleteQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); + const [response] = await client.deleteQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resumeQueue(request), expectedError); - }); + it('invokes deleteQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteQueue( + 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.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('uploadQueueYaml', () => { - it('invokes uploadQueueYaml without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.uploadQueueYaml = stubSimpleCall(expectedResponse); - const [response] = await client.uploadQueueYaml(request); - assert.deepStrictEqual(response, expectedResponse); - }); + it('invokes deleteQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uploadQueueYaml without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.uploadQueueYaml = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.uploadQueueYaml( - 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); - }); + it('invokes deleteQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteQueue(request), expectedError); + }); + }); + + describe('purgeQueue', () => { + it('invokes purgeQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.purgeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uploadQueueYaml with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest() - ); - const expectedError = new Error('expected'); - client.innerApiCalls.uploadQueueYaml = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.uploadQueueYaml(request), expectedError); - }); + it('invokes purgeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.purgeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes uploadQueueYaml with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest() - ); - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.uploadQueueYaml(request), expectedError); - }); + it('invokes purgeQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.purgeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes purgeQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.purgeQueue(request), expectedError); + }); + }); + + describe('pauseQueue', () => { + it('invokes pauseQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); + const [response] = await client.pauseQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.pauseQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.pauseQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); + it('invokes pauseQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.pauseQueue(request), expectedError); + }); + }); + + describe('resumeQueue', () => { + it('invokes resumeQueue without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.resumeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Queue(), + ); + client.innerApiCalls.resumeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resumeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resumeQueue(request), expectedError); + }); + }); + + describe('uploadQueueYaml', () => { + it('invokes uploadQueueYaml without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.uploadQueueYaml = stubSimpleCall(expectedResponse); + const [response] = await client.uploadQueueYaml(request); + assert.deepStrictEqual(response, expectedResponse); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); + it('invokes uploadQueueYaml without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest(), + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.uploadQueueYaml = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.uploadQueueYaml( + 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); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes uploadQueueYaml with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest(), + ); + const expectedError = new Error('expected'); + client.innerApiCalls.uploadQueueYaml = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.uploadQueueYaml(request), expectedError); + }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes uploadQueueYaml with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.UploadQueueYamlRequest(), + ); + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.uploadQueueYaml(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); + it('invokes getIamPolicy with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTask', () => { - it('invokes getTask without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTask(request), expectedError); - }); + it('invokes setIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTask', () => { - it('invokes createTask without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); - const [response] = await client.createTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.createTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTask(request), expectedError); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('getTask', () => { + it('invokes getTask without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTask(request), expectedError); - }); + it('invokes getTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.getTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTask', () => { - it('invokes deleteTask without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTask( - 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.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('createTask', () => { + it('invokes createTask without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); + const [response] = await client.createTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTask(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.createTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTask(request), expectedError); - }); + it('invokes createTask with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('leaseTasks', () => { - it('invokes leaseTasks without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.LeaseTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksResponse() - ); - client.innerApiCalls.leaseTasks = stubSimpleCall(expectedResponse); - const [response] = await client.leaseTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTask(request), expectedError); + }); + }); + + describe('deleteTask', () => { + it('invokes deleteTask without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes leaseTasks without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.LeaseTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksResponse() - ); - client.innerApiCalls.leaseTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.leaseTasks( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTask( + 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.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes leaseTasks with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.LeaseTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.leaseTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.leaseTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.leaseTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes leaseTasks with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.LeaseTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.leaseTasks(request), expectedError); - }); + it('invokes deleteTask with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTask(request), expectedError); + }); + }); + + describe('leaseTasks', () => { + it('invokes leaseTasks without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.LeaseTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksResponse(), + ); + client.innerApiCalls.leaseTasks = stubSimpleCall(expectedResponse); + const [response] = await client.leaseTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('acknowledgeTask', () => { - it('invokes acknowledgeTask without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.acknowledgeTask = stubSimpleCall(expectedResponse); - const [response] = await client.acknowledgeTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.acknowledgeTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acknowledgeTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes leaseTasks without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.LeaseTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksResponse(), + ); + client.innerApiCalls.leaseTasks = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.leaseTasks( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ILeaseTasksResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acknowledgeTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.acknowledgeTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.acknowledgeTask( - 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.acknowledgeTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acknowledgeTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes leaseTasks with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.LeaseTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.leaseTasks = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.leaseTasks(request), expectedError); + const actualRequest = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.leaseTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acknowledgeTask with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.acknowledgeTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.acknowledgeTask(request), expectedError); - const actualRequest = (client.innerApiCalls.acknowledgeTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.acknowledgeTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes leaseTasks with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.LeaseTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.LeaseTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.leaseTasks(request), expectedError); + }); + }); + + describe('acknowledgeTask', () => { + it('invokes acknowledgeTask without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.acknowledgeTask = stubSimpleCall(expectedResponse); + const [response] = await client.acknowledgeTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.acknowledgeTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acknowledgeTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes acknowledgeTask with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.acknowledgeTask(request), expectedError); - }); + it('invokes acknowledgeTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.acknowledgeTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.acknowledgeTask( + 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.acknowledgeTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acknowledgeTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('renewLease', () => { - it('invokes renewLease without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RenewLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.renewLease = stubSimpleCall(expectedResponse); - const [response] = await client.renewLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acknowledgeTask with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.acknowledgeTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.acknowledgeTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.acknowledgeTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.acknowledgeTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes renewLease without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RenewLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.renewLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.renewLease( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes acknowledgeTask with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.AcknowledgeTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.acknowledgeTask(request), expectedError); + }); + }); + + describe('renewLease', () => { + it('invokes renewLease without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RenewLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.renewLease = stubSimpleCall(expectedResponse); + const [response] = await client.renewLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes renewLease with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RenewLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.renewLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.renewLease(request), expectedError); - const actualRequest = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.renewLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes renewLease without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RenewLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.renewLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.renewLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes renewLease with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RenewLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.renewLease(request), expectedError); - }); + it('invokes renewLease with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RenewLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.renewLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.renewLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.renewLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('cancelLease', () => { - it('invokes cancelLease without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CancelLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.cancelLease = stubSimpleCall(expectedResponse); - const [response] = await client.cancelLease(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes renewLease with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RenewLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RenewLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.renewLease(request), expectedError); + }); + }); + + describe('cancelLease', () => { + it('invokes cancelLease without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CancelLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.cancelLease = stubSimpleCall(expectedResponse); + const [response] = await client.cancelLease(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes cancelLease without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CancelLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.cancelLease = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.cancelLease( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes cancelLease without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CancelLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.cancelLease = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.cancelLease( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes cancelLease with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CancelLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.cancelLease = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.cancelLease(request), expectedError); - const actualRequest = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.cancelLease as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes cancelLease with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CancelLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.cancelLease = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.cancelLease(request), expectedError); + const actualRequest = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.cancelLease as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes cancelLease with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.CancelLeaseRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.cancelLease(request), expectedError); - }); + it('invokes cancelLease with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.CancelLeaseRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.CancelLeaseRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.cancelLease(request), expectedError); + }); + }); + + describe('runTask', () => { + it('invokes runTask without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); + const [response] = await client.runTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('runTask', () => { - it('invokes runTask without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); - const [response] = await client.runTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.Task(), + ); + client.innerApiCalls.runTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.Task() - ); - client.innerApiCalls.runTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runTask(request), expectedError); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runTask(request), expectedError); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with closed client', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.runTask(request), expectedError); + }); + }); + + describe('listQueues', () => { + it('invokes listQueues without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + ]; + client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); + const [response] = await client.listQueues(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with closed client', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.runTask(request), expectedError); - }); + it('invokes listQueues without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + ]; + client.innerApiCalls.listQueues = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listQueues( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.IQueue[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listQueues', () => { - it('invokes listQueues without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); - const [response] = await client.listQueues(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueues with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listQueues = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listQueues(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listQueues without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listQueues( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.IQueue[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + ]; + client.descriptors.page.listQueues.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta2.Queue[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta2.Queue) => { + 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.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueues with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listQueues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listQueues(request), expectedError); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta2.Queue[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta2.Queue) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - ]; - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta2.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta2.Queue) => { - 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.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), + ]; + client.descriptors.page.listQueues.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2beta2.IQueue[] = []; + const iterable = client.listQueuesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta2.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta2.Queue) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listQueuesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2beta2.IQueue[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listQueues without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Queue()), - ]; - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2beta2.IQueue[] = []; - const iterable = client.listQueuesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTasks without error using callback', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + ]; + client.innerApiCalls.listTasks = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta2.ITask[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listQueues with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listQueuesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2beta2.IQueue[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.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.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta2.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTasks with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTasksStream without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta2.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta2.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + ]; + client.descriptors.page.listTasks.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta2.Task[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta2.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTasksStream with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta2.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta2.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta2.Task[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta2.Task) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks without error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2beta2.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks without error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta2.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2beta2.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks with error', async () => { - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta2.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta2.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2beta2.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks with error', async () => { + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta2.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta2.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2beta2.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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 cloudtasksModule.v2beta2.CloudTasksClient({ - 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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 cloudtasksModule.v2beta2.CloudTasksClient({ + 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('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('queue', () => { - const fakePath = "/rendered/path/queue"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - }; - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.queuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.queuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('queuePath', () => { - const result = client.queuePath("projectValue", "locationValue", "queueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.queuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromQueueName', () => { - const result = client.matchProjectFromQueueName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromQueueName', () => { - const result = client.matchLocationFromQueueName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromQueueName', () => { - const result = client.matchQueueFromQueueName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('queue', () => { + const fakePath = '/rendered/path/queue'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + }; + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.queuePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.queuePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('queuePath', () => { + const result = client.queuePath( + 'projectValue', + 'locationValue', + 'queueValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.queuePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromQueueName', () => { + const result = client.matchProjectFromQueueName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromQueueName', () => { + const result = client.matchLocationFromQueueName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromQueueName', () => { + const result = client.matchQueueFromQueueName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - task: "taskValue", - }; - const client = new cloudtasksModule.v2beta2.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "queueValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromTaskName', () => { - const result = client.matchQueueFromTaskName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('task', () => { + const fakePath = '/rendered/path/task'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + task: 'taskValue', + }; + const client = new cloudtasksModule.v2beta2.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.taskPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.taskPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath( + 'projectValue', + 'locationValue', + 'queueValue', + 'taskValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromTaskName', () => { + const result = client.matchQueueFromTaskName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, 'taskValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta3.ts b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta3.ts index fc7422893dc1..b0d13fcebf8f 100644 --- a/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta3.ts +++ b/packages/google-cloud-tasks/esm/test/gapic_cloud_tasks_v2beta3.ts @@ -20,16 +20,16 @@ import * as protos from '../../protos/protos.js'; import 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 cloudtasksModule from '../src/index.js'; -import {PassThrough} from 'stream'; +import { PassThrough } from 'stream'; -import {protobuf, LocationProtos} from 'google-gax'; +import { protobuf, LocationProtos } from 'google-gax'; import fs from 'fs'; import path from 'path'; -import {fileURLToPath} from 'url'; +import { fileURLToPath } from 'url'; // @ts-ignore const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -37,2577 +37,3178 @@ const dirname = path.dirname(fileURLToPath(import.meta.url)); // to fill in default values for request objects const root = protobuf.Root.fromJSON( JSON.parse( - fs.readFileSync(path.join(dirname, '..', '..', 'protos/protos.json'), 'utf8') - )) + fs.readFileSync( + path.join(dirname, '..', '..', 'protos/protos.json'), + 'utf8', + ), + ), +); // 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 ?? null; + 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 ?? null; } 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('v2beta3.CloudTasksClient', () => { - describe('Common methods', () => { - it('has apiEndpoint', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient(); - const apiEndpoint = client.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - }); - - it('has universeDomain', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient(); - 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 = cloudtasksModule.v2beta3.CloudTasksClient.servicePath; - assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - - it('throws DeprecationWarning if static apiEndpoint is used', () => { - const stub = sinon.stub(process, 'emitWarning'); - const apiEndpoint = cloudtasksModule.v2beta3.CloudTasksClient.apiEndpoint; - assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); - assert(stub.called); - stub.restore(); - }); - } - it('sets apiEndpoint according to universe domain camelCase', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({universeDomain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.example.com'); - }); - - it('sets apiEndpoint according to universe domain snakeCase', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({universe_domain: 'example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta3.CloudTasksClient(); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta3.CloudTasksClient({universeDomain: 'configured.example.com'}); - const servicePath = client.apiEndpoint; - assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta3.CloudTasksClient({universe_domain: 'example.com', universeDomain: 'example.net'}); }); - }); - - it('has port', () => { - const port = cloudtasksModule.v2beta3.CloudTasksClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - await client.initialize(); - assert(client.cloudTasksStub); - }); - - it('has close method for the initialized client', done => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - assert(client.cloudTasksStub); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has close method for the non-initialized client', done => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.cloudTasksStub, undefined); - client.close().then(() => { - done(); - }).catch(err => {throw err}); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); }); - describe('getQueue', () => { - it('invokes getQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); - const [response] = await client.getQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes getQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.getQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has universeDomain', () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); - it('invokes getQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.getQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getQueue 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 = + cloudtasksModule.v2beta3.CloudTasksClient.servicePath; + assert.strictEqual(servicePath, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + cloudtasksModule.v2beta3.CloudTasksClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'cloudtasks.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); + }); - it('invokes getQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getQueue(request), expectedError); - }); + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.example.com'); }); - describe('createQueue', () => { - it('invokes createQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); - const [response] = await client.createQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue 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 cloudtasksModule.v2beta3.CloudTasksClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta3.CloudTasksClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'cloudtasks.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 cloudtasksModule.v2beta3.CloudTasksClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', }); + }); + }); - it('invokes createQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.createQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('has port', () => { + const port = cloudtasksModule.v2beta3.CloudTasksClient.port; + assert(port); + assert(typeof port === 'number'); + }); - it('invokes createQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.createQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createQueue 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 cloudtasksModule.v2beta3.CloudTasksClient(); + assert(client); + }); - it('invokes createQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateQueueRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createQueue(request), expectedError); - }); + it('should create a client with gRPC fallback', () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + fallback: true, + }); + assert(client); }); - describe('updateQueue', () => { - it('invokes updateQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); - const [response] = await client.updateQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + await client.initialize(); + assert(client.cloudTasksStub); + }); - it('invokes updateQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.updateQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + assert(client.cloudTasksStub); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.updateQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.updateQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.updateQueue 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 cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + assert.strictEqual(client.cloudTasksStub, undefined); + client + .close() + .then(() => { + done(); + }) + .catch((err) => { + throw err; }); + }); - it('invokes updateQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest() - ); - request.queue ??= {}; - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.UpdateQueueRequest', ['queue', 'name']); - request.queue.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.updateQueue(request), expectedError); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + 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('deleteQueue', () => { - it('invokes deleteQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); - const [response] = await client.deleteQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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('getQueue', () => { + it('invokes getQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.getQueue = stubSimpleCall(expectedResponse); + const [response] = await client.getQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteQueue( - 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.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.getQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getQueue = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteQueue(request), expectedError); - }); + it('invokes getQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getQueue(request), expectedError); + }); + }); + + describe('createQueue', () => { + it('invokes createQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.createQueue = stubSimpleCall(expectedResponse); + const [response] = await client.createQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('purgeQueue', () => { - it('invokes purgeQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.purgeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.createQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.purgeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.purgeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.purgeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.purgeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.purgeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateQueueRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createQueue(request), expectedError); + }); + }); + + describe('updateQueue', () => { + it('invokes updateQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.updateQueue = stubSimpleCall(expectedResponse); + const [response] = await client.updateQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes purgeQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PurgeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.purgeQueue(request), expectedError); - }); + it('invokes updateQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.updateQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('pauseQueue', () => { - it('invokes pauseQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); - const [response] = await client.pauseQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedHeaderRequestParams = `queue.name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.updateQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.updateQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.updateQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.pauseQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.pauseQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes updateQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.UpdateQueueRequest(), + ); + request.queue ??= {}; + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.UpdateQueueRequest', + ['queue', 'name'], + ); + request.queue.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.updateQueue(request), expectedError); + }); + }); + + describe('deleteQueue', () => { + it('invokes deleteQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = stubSimpleCall(expectedResponse); + const [response] = await client.deleteQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.pauseQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.pauseQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.pauseQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteQueue( + 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.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes pauseQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.PauseQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.PauseQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.pauseQueue(request), expectedError); - }); + it('invokes deleteQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('resumeQueue', () => { - it('invokes resumeQueue without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); - const [response] = await client.resumeQueue(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteQueue(request), expectedError); + }); + }); + + describe('purgeQueue', () => { + it('invokes purgeQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.purgeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.purgeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Queue() - ); - client.innerApiCalls.resumeQueue = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.resumeQueue( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes purgeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.purgeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.purgeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.resumeQueue = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.resumeQueue(request), expectedError); - const actualRequest = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.resumeQueue as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes purgeQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.purgeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.purgeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.purgeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes resumeQueue with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ResumeQueueRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.resumeQueue(request), expectedError); - }); + it('invokes purgeQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PurgeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PurgeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.purgeQueue(request), expectedError); + }); + }); + + describe('pauseQueue', () => { + it('invokes pauseQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.pauseQueue = stubSimpleCall(expectedResponse); + const [response] = await client.pauseQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.pauseQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.pauseQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.pauseQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.pauseQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.pauseQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes pauseQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.PauseQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.PauseQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.pauseQueue(request), expectedError); + }); + }); + + describe('resumeQueue', () => { + it('invokes resumeQueue without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.resumeQueue = stubSimpleCall(expectedResponse); + const [response] = await client.resumeQueue(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.GetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.GetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); + it('invokes resumeQueue without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Queue(), + ); + client.innerApiCalls.resumeQueue = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.resumeQueue( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.resumeQueue = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.resumeQueue(request), expectedError); + const actualRequest = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.resumeQueue as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.Policy() - ); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes resumeQueue with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ResumeQueueRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ResumeQueueRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.resumeQueue(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - const actualRequest = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.SetIamPolicyRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.SetIamPolicyRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); + it('invokes getIamPolicy with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.GetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsResponse() - ); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy(), + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedHeaderRequestParams = `resource=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - const actualRequest = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + const actualRequest = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.setIamPolicy as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes testIamPermissions with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.iam.v1.TestIamPermissionsRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.iam.v1.TestIamPermissionsRequest', ['resource']); - request.resource = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); + it('invokes setIamPolicy with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.SetIamPolicyRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('getTask', () => { - it('invokes getTask without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); - const [response] = await client.getTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse(), + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.getTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedHeaderRequestParams = `resource=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + const actualRequest = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.testIamPermissions as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTask(request), expectedError); - const actualRequest = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.getTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes testIamPermissions with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.iam.v1.TestIamPermissionsRequest', + ['resource'], + ); + request.resource = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('getTask', () => { + it('invokes getTask without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.getTask = stubSimpleCall(expectedResponse); + const [response] = await client.getTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes getTask with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.GetTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.GetTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.getTask(request), expectedError); - }); + it('invokes getTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.getTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('createTask', () => { - it('invokes createTask without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); - const [response] = await client.createTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.getTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTask(request), expectedError); + const actualRequest = (client.innerApiCalls.getTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.getTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.createTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes getTask with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.GetTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.GetTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.getTask(request), expectedError); + }); + }); + + describe('createTask', () => { + it('invokes createTask without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.createTask = stubSimpleCall(expectedResponse); + const [response] = await client.createTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.createTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTask(request), expectedError); - const actualRequest = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.createTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.createTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes createTask with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.CreateTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.CreateTaskRequest', ['parent']); - request.parent = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.createTask(request), expectedError); - }); + it('invokes createTask with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.createTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('deleteTask', () => { - it('invokes deleteTask without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes createTask with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.CreateTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.CreateTaskRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.createTask(request), expectedError); + }); + }); + + describe('deleteTask', () => { + it('invokes deleteTask without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.innerApiCalls.deleteTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTask( - 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.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty(), + ); + client.innerApiCalls.deleteTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTask( + 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.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTask(request), expectedError); - const actualRequest = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.deleteTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes deleteTask with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTask = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.deleteTask(request), expectedError); + const actualRequest = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.deleteTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes deleteTask with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.DeleteTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.deleteTask(request), expectedError); - }); + it('invokes deleteTask with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.DeleteTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.DeleteTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.deleteTask(request), expectedError); + }); + }); + + describe('runTask', () => { + it('invokes runTask without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); + const [response] = await client.runTask(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('runTask', () => { - it('invokes runTask without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.runTask = stubSimpleCall(expectedResponse); - const [response] = await client.runTask(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.Task(), + ); + client.innerApiCalls.runTask = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runTask( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.ITask | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedResponse = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.Task() - ); - client.innerApiCalls.runTask = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.runTask( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.ITask|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedHeaderRequestParams = `name=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runTask(request), expectedError); + const actualRequest = (client.innerApiCalls.runTask as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.runTask as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedHeaderRequestParams = `name=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.runTask = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.runTask(request), expectedError); - const actualRequest = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.runTask as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes runTask with closed client', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.RunTaskRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.RunTaskRequest', + ['name'], + ); + request.name = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close().catch((err) => { + throw err; + }); + await assert.rejects(client.runTask(request), expectedError); + }); + }); + + describe('listQueues', () => { + it('invokes listQueues without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + ]; + client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); + const [response] = await client.listQueues(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes runTask with closed client', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.RunTaskRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.RunTaskRequest', ['name']); - request.name = defaultValue1; - const expectedError = new Error('The client has already been closed.'); - client.close().catch(err => {throw err}); - await assert.rejects(client.runTask(request), expectedError); - }); + it('invokes listQueues without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + ]; + client.innerApiCalls.listQueues = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listQueues( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.IQueue[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listQueues', () => { - it('invokes listQueues without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCall(expectedResponse); - const [response] = await client.listQueues(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueues with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listQueues = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.listQueues(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listQueues as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listQueues without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - ]; - client.innerApiCalls.listQueues = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listQueues( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.IQueue[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + ]; + client.descriptors.page.listQueues.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta3.Queue[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta3.Queue) => { + 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.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueues with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listQueues = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listQueues(request), expectedError); - const actualRequest = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listQueues as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listQueuesStream with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listQueuesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta3.Queue[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta3.Queue) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listQueues, request), + ); + assert( + (client.descriptors.page.listQueues.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - ]; - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta3.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta3.Queue) => { - 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.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), + ]; + client.descriptors.page.listQueues.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2beta3.IQueue[] = []; + const iterable = client.listQueuesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listQueuesStream with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listQueuesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta3.Queue[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta3.Queue) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listQueues, request)); - assert( - (client.descriptors.page.listQueues.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listQueues with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListQueuesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListQueuesRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listQueuesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2beta3.IQueue[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listQueues.asyncIterate as SinonStub).getCall( + 0, + ).args[1], + request, + ); + assert( + (client.descriptors.page.listQueues.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); + }); + + describe('listTasks', () => { + it('invokes listTasks without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + ]; + client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); + const [response] = await client.listTasks(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('uses async iteration with listQueues without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Queue()), - ]; - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2beta3.IQueue[] = []; - const iterable = client.listQueuesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listTasks without error using callback', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + ]; + client.innerApiCalls.listTasks = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTasks( + request, + ( + err?: Error | null, + result?: protos.google.cloud.tasks.v2beta3.ITask[] | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); - - it('uses async iteration with listQueues with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListQueuesRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListQueuesRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listQueues.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listQueuesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2beta3.IQueue[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listQueues.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listQueues.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.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); }); - describe('listTasks', () => { - it('invokes listTasks without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCall(expectedResponse); - const [response] = await client.listTasks(request); - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks without error using callback', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`;const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - ]; - client.innerApiCalls.listTasks = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTasks( - request, - (err?: Error|null, result?: protos.google.cloud.tasks.v2beta3.ITask[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); - - it('invokes listTasks with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTasks(request), expectedError); - const actualRequest = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[0]; - assert.deepStrictEqual(actualRequest, request); - const actualHeaderRequestParams = (client.innerApiCalls.listTasks as SinonStub) - .getCall(0).args[1].otherArgs.headers['x-goog-request-params']; - assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); - }); + it('invokes listTasks with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.listTasks = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listTasks(request), expectedError); + const actualRequest = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.listTasks as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); - it('invokes listTasksStream without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - ]; - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta3.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta3.Task) => { - 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.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + ]; + client.descriptors.page.listTasks.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta3.Task[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta3.Task) => { + 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.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('invokes listTasksStream with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTasksStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.tasks.v2beta3.Task[] = []; - stream.on('data', (response: protos.google.cloud.tasks.v2beta3.Task) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTasks, request)); - assert( - (client.descriptors.page.listTasks.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('invokes listTasksStream with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.createStream = stubPageStreamingCall( + undefined, + expectedError, + ); + const stream = client.listTasksStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.tasks.v2beta3.Task[] = []; + stream.on( + 'data', + (response: protos.google.cloud.tasks.v2beta3.Task) => { + responses.push(response); + }, + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTasks, request), + ); + assert( + (client.descriptors.page.listTasks.createStream as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks without error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), - ]; - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.tasks.v2beta3.ITask[] = []; - const iterable = client.listTasksAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks without error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + generateSampleMessage(new protos.google.cloud.tasks.v2beta3.Task()), + ]; + client.descriptors.page.listTasks.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.tasks.v2beta3.ITask[] = []; + const iterable = client.listTasksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.asyncIterate as SinonStub) + .getCall(0) + .args[2].otherArgs.headers[ + 'x-goog-request-params' + ].includes(expectedHeaderRequestParams), + ); + }); - it('uses async iteration with listTasks with error', async () => { - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - await client.initialize(); - const request = generateSampleMessage( - new protos.google.cloud.tasks.v2beta3.ListTasksRequest() - ); - const defaultValue1 = - getTypeDefaultValue('.google.cloud.tasks.v2beta3.ListTasksRequest', ['parent']); - request.parent = defaultValue1; - const expectedHeaderRequestParams = `parent=${defaultValue1 ?? '' }`; - const expectedError = new Error('expected'); - client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTasksAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.tasks.v2beta3.ITask[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert( - (client.descriptors.page.listTasks.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'].includes( - expectedHeaderRequestParams - ) - ); - }); + it('uses async iteration with listTasks with error', async () => { + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.tasks.v2beta3.ListTasksRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.tasks.v2beta3.ListTasksRequest', + ['parent'], + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.descriptors.page.listTasks.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError, + ); + const iterable = client.listTasksAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.tasks.v2beta3.ITask[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTasks.asyncIterate as SinonStub).getCall(0) + .args[1], + request, + ); + assert( + (client.descriptors.page.listTasks.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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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 cloudtasksModule.v2beta3.CloudTasksClient({ - 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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 cloudtasksModule.v2beta3.CloudTasksClient({ + 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('location', () => { + const fakePath = '/rendered/path/location'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + }; + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('Path templates', () => { - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - 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', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + 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('queue', () => { - const fakePath = "/rendered/path/queue"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - }; - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.queuePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.queuePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('queuePath', () => { - const result = client.queuePath("projectValue", "locationValue", "queueValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.queuePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromQueueName', () => { - const result = client.matchProjectFromQueueName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromQueueName', () => { - const result = client.matchLocationFromQueueName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromQueueName', () => { - const result = client.matchQueueFromQueueName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.queuePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('queue', () => { + const fakePath = '/rendered/path/queue'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + }; + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.queuePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.queuePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('queuePath', () => { + const result = client.queuePath( + 'projectValue', + 'locationValue', + 'queueValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.queuePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromQueueName', () => { + const result = client.matchProjectFromQueueName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromQueueName', () => { + const result = client.matchLocationFromQueueName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromQueueName', () => { + const result = client.matchQueueFromQueueName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.queuePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + }); - describe('task', () => { - const fakePath = "/rendered/path/task"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - queue: "queueValue", - task: "taskValue", - }; - const client = new cloudtasksModule.v2beta3.CloudTasksClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize().catch(err => {throw err}); - client.pathTemplates.taskPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.taskPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('taskPath', () => { - const result = client.taskPath("projectValue", "locationValue", "queueValue", "taskValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.taskPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTaskName', () => { - const result = client.matchProjectFromTaskName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromTaskName', () => { - const result = client.matchLocationFromTaskName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchQueueFromTaskName', () => { - const result = client.matchQueueFromTaskName(fakePath); - assert.strictEqual(result, "queueValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTaskFromTaskName', () => { - const result = client.matchTaskFromTaskName(fakePath); - assert.strictEqual(result, "taskValue"); - assert((client.pathTemplates.taskPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('task', () => { + const fakePath = '/rendered/path/task'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + queue: 'queueValue', + task: 'taskValue', + }; + const client = new cloudtasksModule.v2beta3.CloudTasksClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.initialize().catch((err) => { + throw err; + }); + client.pathTemplates.taskPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.taskPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('taskPath', () => { + const result = client.taskPath( + 'projectValue', + 'locationValue', + 'queueValue', + 'taskValue', + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.taskPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters), + ); + }); + + it('matchProjectFromTaskName', () => { + const result = client.matchProjectFromTaskName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchLocationFromTaskName', () => { + const result = client.matchLocationFromTaskName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchQueueFromTaskName', () => { + const result = client.matchQueueFromTaskName(fakePath); + assert.strictEqual(result, 'queueValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); + + it('matchTaskFromTaskName', () => { + const result = client.matchTaskFromTaskName(fakePath); + assert.strictEqual(result, 'taskValue'); + assert( + (client.pathTemplates.taskPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath), + ); + }); }); + }); }); diff --git a/packages/google-cloud-tasks/protos/protos.cjs b/packages/google-cloud-tasks/protos/protos.cjs index 9339fda17dc2..2d7940617128 100644 --- a/packages/google-cloud-tasks/protos/protos.cjs +++ b/packages/google-cloud-tasks/protos/protos.cjs @@ -31881,6 +31881,7 @@ * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -31915,6 +31916,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 @@ -31947,6 +31956,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; }; @@ -31998,6 +32009,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; @@ -32049,6 +32064,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; }; @@ -32091,6 +32111,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; }; @@ -32109,8 +32134,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) { @@ -32118,6 +32145,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; }; @@ -33940,6 +33969,7 @@ * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -33965,6 +33995,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 @@ -33991,6 +34029,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; }; @@ -34031,6 +34071,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; @@ -34071,6 +34115,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; }; @@ -34091,6 +34140,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; }; @@ -34107,10 +34161,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; }; @@ -34140,6 +34198,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; })(); @@ -35016,6 +35326,7 @@ * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -35027,6 +35338,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) @@ -35041,6 +35353,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 @@ -35067,6 +35387,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; }; @@ -35097,7 +35420,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) @@ -35107,6 +35430,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; @@ -35147,6 +35493,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; }; @@ -35167,6 +35521,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; }; @@ -35183,10 +35544,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; }; @@ -35825,30 +36194,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; })(); /** @@ -37093,6 +37707,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 @@ -37107,6 +37722,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; @@ -37131,6 +37747,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 @@ -37153,6 +37770,7 @@ this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -37203,6 +37821,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 @@ -37324,6 +37950,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; }; @@ -37396,6 +38025,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 = []; @@ -37498,6 +38133,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"; @@ -37552,6 +38194,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -37604,6 +38247,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"); @@ -37667,6 +38317,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -37732,6 +38386,7 @@ object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -37788,6 +38443,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; }; @@ -37836,6 +38496,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 */ /** @@ -37941,6 +38602,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 @@ -37993,6 +38662,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; }; @@ -38085,6 +38756,10 @@ message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -38198,6 +38873,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; }; @@ -38297,6 +38981,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; }; @@ -38326,6 +39030,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; @@ -38371,6 +39076,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; }; @@ -40415,6 +41122,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 */ /** @@ -40475,6 +41183,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 @@ -40512,6 +41228,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; }; @@ -40574,6 +41292,10 @@ message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -40642,6 +41364,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; }; @@ -40691,6 +41422,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; }; @@ -40715,6 +41466,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; @@ -40735,6 +41487,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; }; @@ -43053,6 +43807,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 @@ -43173,6 +43928,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 @@ -43247,6 +44010,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(); @@ -43348,6 +44113,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 = []; @@ -43483,6 +44252,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"; @@ -43671,6 +44445,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"); @@ -43768,6 +44547,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")) @@ -43800,6 +44580,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) @@ -44072,6 +44854,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -44113,103 +44896,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; @@ -44804,6 +46073,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 */ @@ -44847,6 +46117,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 @@ -44885,6 +46163,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(); @@ -44936,6 +46216,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 = []; @@ -44988,6 +46272,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"; @@ -45021,6 +46310,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"); @@ -45053,6 +46347,7 @@ object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -45060,6 +46355,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) @@ -46499,6 +47796,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 */ /** @@ -46564,6 +47863,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 @@ -46600,6 +47915,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; }; @@ -46660,6 +47979,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; @@ -46750,6 +48077,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; }; @@ -46889,6 +48236,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; }; @@ -46912,6 +48307,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; @@ -46925,6 +48322,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; }; @@ -47052,6 +48453,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; })(); @@ -47236,6 +48850,7 @@ default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47253,6 +48868,7 @@ default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47301,6 +48917,10 @@ case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -47353,6 +48973,10 @@ case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -47461,7 +49085,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 */ /** @@ -47488,12 +49113,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. @@ -47519,10 +49152,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; }; @@ -47563,8 +49198,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: @@ -47607,6 +49246,7 @@ default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47619,10 +49259,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; }; @@ -47650,6 +49295,10 @@ case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -47691,10 +49340,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; }; @@ -47713,13 +49367,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; }; @@ -48934,6 +50591,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-tasks/protos/protos.d.ts b/packages/google-cloud-tasks/protos/protos.d.ts index 338ef8229bc6..13e257b3f5c4 100644 --- a/packages/google-cloud-tasks/protos/protos.d.ts +++ b/packages/google-cloud-tasks/protos/protos.d.ts @@ -13047,6 +13047,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -13064,6 +13067,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 @@ -13764,6 +13770,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -13778,6 +13787,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 @@ -13856,6 +13868,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 { @@ -14182,6 +14306,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -14196,6 +14323,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 @@ -14520,6 +14650,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, @@ -15010,6 +15243,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -15040,6 +15274,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -15089,6 +15326,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -15223,6 +15463,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -15264,6 +15507,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 @@ -16111,6 +16357,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -16137,6 +16386,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 @@ -17071,6 +17323,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); @@ -17126,6 +17381,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[]; @@ -17346,6 +17604,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. */ @@ -17584,6 +17957,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -17606,6 +17982,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[]; @@ -18195,6 +18574,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. */ @@ -18224,6 +18609,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 @@ -18346,6 +18737,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. */ @@ -18465,8 +18966,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. */ @@ -18481,8 +18985,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. @@ -19015,6 +19522,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-tasks/protos/protos.js b/packages/google-cloud-tasks/protos/protos.js index a973f0410c8a..2a6ea0696ced 100644 --- a/packages/google-cloud-tasks/protos/protos.js +++ b/packages/google-cloud-tasks/protos/protos.js @@ -31872,6 +31872,7 @@ export const google = $root.google = (() => { * @interface ICommonLanguageSettings * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration */ /** @@ -31906,6 +31907,14 @@ export const google = $root.google = (() => { */ 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 @@ -31938,6 +31947,8 @@ export const google = $root.google = (() => { 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; }; @@ -31989,6 +32000,10 @@ export const google = $root.google = (() => { 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; @@ -32040,6 +32055,11 @@ export const google = $root.google = (() => { break; } } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + let error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } return null; }; @@ -32082,6 +32102,11 @@ export const google = $root.google = (() => { 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; }; @@ -32100,8 +32125,10 @@ export const google = $root.google = (() => { let 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) { @@ -32109,6 +32136,8 @@ export const google = $root.google = (() => { for (let 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; }; @@ -33931,6 +33960,7 @@ export const google = $root.google = (() => { * @memberof google.api * @interface IPythonSettings * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures */ /** @@ -33956,6 +33986,14 @@ export const google = $root.google = (() => { */ 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 @@ -33982,6 +34020,8 @@ export const google = $root.google = (() => { 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; }; @@ -34022,6 +34062,10 @@ export const google = $root.google = (() => { 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; @@ -34062,6 +34106,11 @@ export const google = $root.google = (() => { if (error) return "common." + error; } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + let error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } return null; }; @@ -34082,6 +34131,11 @@ export const google = $root.google = (() => { 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; }; @@ -34098,10 +34152,14 @@ export const google = $root.google = (() => { if (!options) options = {}; let 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; }; @@ -34131,6 +34189,258 @@ export const google = $root.google = (() => { 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 (let 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); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + let 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; + let 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 = {}; + let 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; })(); @@ -35007,6 +35317,7 @@ export const google = $root.google = (() => { * @memberof google.api * @interface IGoSettings * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices */ /** @@ -35018,6 +35329,7 @@ export const google = $root.google = (() => { * @param {google.api.IGoSettings=} [properties] Properties to set */ function GoSettings(properties) { + this.renamedServices = {}; if (properties) for (let keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -35032,6 +35344,14 @@ export const google = $root.google = (() => { */ 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 @@ -35058,6 +35378,9 @@ export const google = $root.google = (() => { 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 (let 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; }; @@ -35088,7 +35411,7 @@ export const google = $root.google = (() => { GoSettings.decode = function decode(reader, length, error) { if (!(reader instanceof $Reader)) reader = $Reader.create(reader); - let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; while (reader.pos < end) { let tag = reader.uint32(); if (tag === error) @@ -35098,6 +35421,29 @@ export const google = $root.google = (() => { message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); break; } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + let end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + let 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; @@ -35138,6 +35484,14 @@ export const google = $root.google = (() => { if (error) return "common." + error; } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + let key = Object.keys(message.renamedServices); + for (let i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } return null; }; @@ -35158,6 +35512,13 @@ export const google = $root.google = (() => { 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 (let keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } return message; }; @@ -35174,10 +35535,18 @@ export const google = $root.google = (() => { if (!options) options = {}; let 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); + let keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (let j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } return object; }; @@ -35816,30 +36185,275 @@ export const google = $root.google = (() => { 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() { - const 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 (let 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 (let 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); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + let 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 (let 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; + let 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 (let 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 = {}; + let object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (let 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() { + const 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; })(); /** @@ -37084,6 +37698,7 @@ export const google = $root.google = (() => { * @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 @@ -37098,6 +37713,7 @@ export const google = $root.google = (() => { protobuf.Edition = (function() { const 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; @@ -37122,6 +37738,7 @@ export const google = $root.google = (() => { * @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 @@ -37144,6 +37761,7 @@ export const google = $root.google = (() => { this.dependency = []; this.publicDependency = []; this.weakDependency = []; + this.optionDependency = []; this.messageType = []; this.enumType = []; this.service = []; @@ -37194,6 +37812,14 @@ export const google = $root.google = (() => { */ 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 @@ -37315,6 +37941,9 @@ export const google = $root.google = (() => { 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 (let i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); return writer; }; @@ -37387,6 +38016,12 @@ export const google = $root.google = (() => { 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 = []; @@ -37489,6 +38124,13 @@ export const google = $root.google = (() => { 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 (let 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"; @@ -37543,6 +38185,7 @@ export const google = $root.google = (() => { default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -37595,6 +38238,13 @@ export const google = $root.google = (() => { for (let 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 (let 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"); @@ -37658,6 +38308,10 @@ export const google = $root.google = (() => { case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -37723,6 +38377,7 @@ export const google = $root.google = (() => { object.extension = []; object.publicDependency = []; object.weakDependency = []; + object.optionDependency = []; } if (options.defaults) { object.name = ""; @@ -37779,6 +38434,11 @@ export const google = $root.google = (() => { 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 (let j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } return object; }; @@ -37827,6 +38487,7 @@ export const google = $root.google = (() => { * @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 */ /** @@ -37932,6 +38593,14 @@ export const google = $root.google = (() => { */ 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 @@ -37984,6 +38653,8 @@ export const google = $root.google = (() => { if (message.reservedName != null && message.reservedName.length) for (let 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; }; @@ -38076,6 +38747,10 @@ export const google = $root.google = (() => { message.reservedName.push(reader.string()); break; } + case 11: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -38189,6 +38864,15 @@ export const google = $root.google = (() => { 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; }; @@ -38288,6 +38972,26 @@ export const google = $root.google = (() => { for (let 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; }; @@ -38317,6 +39021,7 @@ export const google = $root.google = (() => { 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; @@ -38362,6 +39067,8 @@ export const google = $root.google = (() => { for (let 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; }; @@ -40406,6 +41113,7 @@ export const google = $root.google = (() => { * @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 */ /** @@ -40466,6 +41174,14 @@ export const google = $root.google = (() => { */ 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 @@ -40503,6 +41219,8 @@ export const google = $root.google = (() => { if (message.reservedName != null && message.reservedName.length) for (let 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; }; @@ -40565,6 +41283,10 @@ export const google = $root.google = (() => { message.reservedName.push(reader.string()); break; } + case 6: { + message.visibility = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -40633,6 +41355,15 @@ export const google = $root.google = (() => { 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; }; @@ -40682,6 +41413,26 @@ export const google = $root.google = (() => { for (let 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; }; @@ -40706,6 +41457,7 @@ export const google = $root.google = (() => { 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; @@ -40726,6 +41478,8 @@ export const google = $root.google = (() => { for (let 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; }; @@ -43044,6 +43798,7 @@ export const google = $root.google = (() => { * @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 @@ -43164,6 +43919,14 @@ export const google = $root.google = (() => { */ 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 @@ -43238,6 +44001,8 @@ export const google = $root.google = (() => { $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 (let i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -43339,6 +44104,10 @@ export const google = $root.google = (() => { 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 = []; @@ -43474,6 +44243,11 @@ export const google = $root.google = (() => { if (error) return "features." + error; } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + let 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"; @@ -43662,6 +44436,11 @@ export const google = $root.google = (() => { 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"); @@ -43759,6 +44538,7 @@ export const google = $root.google = (() => { 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")) @@ -43791,6 +44571,8 @@ export const google = $root.google = (() => { } 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 (let j = 0; j < message.uninterpretedOption.length; ++j) @@ -44063,6 +44845,7 @@ export const google = $root.google = (() => { default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -44104,103 +44887,589 @@ export const google = $root.google = (() => { 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 = {}; + let 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 (let 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); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + let 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; + let 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 = {}; let 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; @@ -44795,6 +46064,7 @@ export const google = $root.google = (() => { * @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 */ @@ -44838,6 +46108,14 @@ export const google = $root.google = (() => { */ 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 @@ -44876,6 +46154,8 @@ export const google = $root.google = (() => { $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 (let i = 0; i < message.uninterpretedOption.length; ++i) $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); @@ -44927,6 +46207,10 @@ export const google = $root.google = (() => { 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 = []; @@ -44979,6 +46263,11 @@ export const google = $root.google = (() => { if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) if (typeof message.debugRedact !== "boolean") return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + let 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"; @@ -45012,6 +46301,11 @@ export const google = $root.google = (() => { } 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"); @@ -45044,6 +46338,7 @@ export const google = $root.google = (() => { object.deprecated = false; object.features = null; object.debugRedact = false; + object.featureSupport = null; } if (message.deprecated != null && message.hasOwnProperty("deprecated")) object.deprecated = message.deprecated; @@ -45051,6 +46346,8 @@ export const google = $root.google = (() => { 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 (let j = 0; j < message.uninterpretedOption.length; ++j) @@ -46490,6 +47787,8 @@ export const google = $root.google = (() => { * @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 */ /** @@ -46555,6 +47854,22 @@ export const google = $root.google = (() => { */ 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 @@ -46591,6 +47906,10 @@ export const google = $root.google = (() => { 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; }; @@ -46651,6 +47970,14 @@ export const google = $root.google = (() => { 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; @@ -46741,6 +48068,26 @@ export const google = $root.google = (() => { 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; }; @@ -46880,6 +48227,54 @@ export const google = $root.google = (() => { 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; }; @@ -46903,6 +48298,8 @@ export const google = $root.google = (() => { 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; @@ -46916,6 +48313,10 @@ export const google = $root.google = (() => { 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; }; @@ -47043,6 +48444,219 @@ export const google = $root.google = (() => { 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() { + const 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 (let 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); + let end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + let 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() { + const 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; })(); @@ -47227,6 +48841,7 @@ export const google = $root.google = (() => { default: return "minimumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47244,6 +48859,7 @@ export const google = $root.google = (() => { default: return "maximumEdition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47292,6 +48908,10 @@ export const google = $root.google = (() => { case 0: message.minimumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.minimumEdition = 998; @@ -47344,6 +48964,10 @@ export const google = $root.google = (() => { case 0: message.maximumEdition = 0; break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; case "EDITION_PROTO2": case 998: message.maximumEdition = 998; @@ -47452,7 +49076,8 @@ export const google = $root.google = (() => { * @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 */ /** @@ -47479,12 +49104,20 @@ export const google = $root.google = (() => { 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. @@ -47510,10 +49143,12 @@ export const google = $root.google = (() => { 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; }; @@ -47554,8 +49189,12 @@ export const google = $root.google = (() => { 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: @@ -47598,6 +49237,7 @@ export const google = $root.google = (() => { default: return "edition: enum value expected"; case 0: + case 900: case 998: case 999: case 1000: @@ -47610,10 +49250,15 @@ export const google = $root.google = (() => { case 2147483647: break; } - if (message.features != null && message.hasOwnProperty("features")) { - let error = $root.google.protobuf.FeatureSet.verify(message.features); + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + let error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + let error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); if (error) - return "features." + error; + return "fixedFeatures." + error; } return null; }; @@ -47641,6 +49286,10 @@ export const google = $root.google = (() => { case 0: message.edition = 0; break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; case "EDITION_PROTO2": case 998: message.edition = 998; @@ -47682,10 +49331,15 @@ export const google = $root.google = (() => { 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; }; @@ -47704,13 +49358,16 @@ export const google = $root.google = (() => { options = {}; let 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; }; @@ -48925,6 +50582,22 @@ export const google = $root.google = (() => { 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() { + const 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-tasks/protos/protos.json b/packages/google-cloud-tasks/protos/protos.json index 8051945cdc00..fecfa90bcf3c 100644 --- a/packages/google-cloud-tasks/protos/protos.json +++ b/packages/google-cloud-tasks/protos/protos.json @@ -3351,8 +3351,7 @@ "java_multiple_files": true, "java_outer_classname": "HttpBodyProto", "java_package": "com.google.api", - "objc_class_prefix": "GAPI", - "cc_enable_arenas": true + "objc_class_prefix": "GAPI" }, "nested": { "http": { @@ -3476,6 +3475,10 @@ "rule": "repeated", "type": "ClientLibraryDestination", "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 } } }, @@ -3616,6 +3619,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 + } + } } } }, @@ -3673,6 +3698,11 @@ "common": { "type": "CommonLanguageSettings", "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 } } }, @@ -3734,6 +3764,19 @@ "PACKAGE_MANAGER": 20 } }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, "LaunchStage": { "values": { "LAUNCH_STAGE_UNSPECIFIED": 0, @@ -3883,12 +3926,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, @@ -3927,6 +3977,11 @@ "type": "int32", "id": 11 }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, "messageType": { "rule": "repeated", "type": "DescriptorProto", @@ -4015,6 +4070,10 @@ "rule": "repeated", "type": "string", "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 } }, "nested": { @@ -4240,6 +4299,10 @@ "rule": "repeated", "type": "string", "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 } }, "nested": { @@ -4290,7 +4353,14 @@ "type": "ServiceOptions", "id": 3 } - } + }, + "reserved": [ + [ + 4, + 4 + ], + "stream" + ] }, "MethodDescriptorProto": { "edition": "proto2", @@ -4454,6 +4524,7 @@ 42, 42 ], + "php_generic_services", [ 38, 38 @@ -4589,7 +4660,8 @@ "type": "bool", "id": 10, "options": { - "default": false + "default": false, + "deprecated": true } }, "debugRedact": { @@ -4617,6 +4689,10 @@ "type": "FeatureSet", "id": 21 }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -4686,6 +4762,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 + } + } } } }, @@ -4774,6 +4870,10 @@ "default": false } }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, "uninterpretedOption": { "rule": "repeated", "type": "UninterpretedOption", @@ -4916,6 +5016,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_2023", "edition_defaults.value": "EXPLICIT" } @@ -4926,6 +5027,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "OPEN" } @@ -4936,6 +5038,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "PACKED" } @@ -4946,6 +5049,7 @@ "options": { "retention": "RETENTION_RUNTIME", "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", "edition_defaults.edition": "EDITION_PROTO3", "edition_defaults.value": "VERIFY" } @@ -4956,7 +5060,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" } }, @@ -4966,27 +5071,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, @@ -5031,7 +5147,13 @@ "UTF8_VALIDATION_UNKNOWN": 0, "VERIFY": 2, "NONE": 3 - } + }, + "reserved": [ + [ + 1, + 1 + ] + ] }, "MessageEncoding": { "values": { @@ -5046,6 +5168,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 + } + } + } } } }, @@ -5073,11 +5222,26 @@ "type": "Edition", "id": 3 }, - "features": { + "overridableFeatures": { "type": "FeatureSet", - "id": 2 + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 } - } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] } } }, @@ -5090,6 +5254,12 @@ "id": 1 } }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], "nested": { "Location": { "fields": { @@ -5175,6 +5345,14 @@ } } }, + "SymbolVisibility": { + "edition": "proto2", + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, "Duration": { "fields": { "seconds": { @@ -5258,13 +5436,13 @@ "nested": { "v1": { "options": { - "cc_enable_arenas": true, "csharp_namespace": "Google.Cloud.Iam.V1", "go_package": "cloud.google.com/go/iam/apiv1/iampb;iampb", "java_multiple_files": true, "java_outer_classname": "PolicyProto", "java_package": "com.google.iam.v1", - "php_namespace": "Google\\Cloud\\Iam\\V1" + "php_namespace": "Google\\Cloud\\Iam\\V1", + "cc_enable_arenas": true }, "nested": { "IAMPolicy": { diff --git a/packages/google-cloud-tasks/samples/generated/v2/snippet_metadata_google.cloud.tasks.v2.json b/packages/google-cloud-tasks/samples/generated/v2/snippet_metadata_google.cloud.tasks.v2.json index f8117f7b0093..f8320985590c 100644 --- a/packages/google-cloud-tasks/samples/generated/v2/snippet_metadata_google.cloud.tasks.v2.json +++ b/packages/google-cloud-tasks/samples/generated/v2/snippet_metadata_google.cloud.tasks.v2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-tasks", - "version": "6.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-tasks/samples/generated/v2beta2/snippet_metadata_google.cloud.tasks.v2beta2.json b/packages/google-cloud-tasks/samples/generated/v2beta2/snippet_metadata_google.cloud.tasks.v2beta2.json index 6964228782b5..6cce7d638c96 100644 --- a/packages/google-cloud-tasks/samples/generated/v2beta2/snippet_metadata_google.cloud.tasks.v2beta2.json +++ b/packages/google-cloud-tasks/samples/generated/v2beta2/snippet_metadata_google.cloud.tasks.v2beta2.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-tasks", - "version": "6.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-tasks/samples/generated/v2beta3/snippet_metadata_google.cloud.tasks.v2beta3.json b/packages/google-cloud-tasks/samples/generated/v2beta3/snippet_metadata_google.cloud.tasks.v2beta3.json index 8c6d4740a16f..2a8b89bb0e60 100644 --- a/packages/google-cloud-tasks/samples/generated/v2beta3/snippet_metadata_google.cloud.tasks.v2beta3.json +++ b/packages/google-cloud-tasks/samples/generated/v2beta3/snippet_metadata_google.cloud.tasks.v2beta3.json @@ -1,7 +1,7 @@ { "clientLibrary": { "name": "nodejs-tasks", - "version": "6.2.1", + "version": "0.1.0", "language": "TYPESCRIPT", "apis": [ { diff --git a/packages/google-cloud-tasks/tsconfig.json b/packages/google-cloud-tasks/tsconfig.json index a51f848f0915..110f6eccd41b 100644 --- a/packages/google-cloud-tasks/tsconfig.json +++ b/packages/google-cloud-tasks/tsconfig.json @@ -1,5 +1,4 @@ { - // This file is handwritten since this library has a dual-publication setup (ESM and CJS) "extends": "./node_modules/gts/tsconfig-google.json", "compilerOptions": { "rootDir": ".", diff --git a/packages/google-cloud-tasks/webpack.config.cjs b/packages/google-cloud-tasks/webpack.config.cjs index 40479de6a985..007acb6169bb 100644 --- a/packages/google-cloud-tasks/webpack.config.cjs +++ b/packages/google-cloud-tasks/webpack.config.cjs @@ -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-telcoautomation/.eslintignore b/packages/google-cloud-telcoautomation/.eslintignore new file mode 100644 index 000000000000..cfc348ec4d11 --- /dev/null +++ b/packages/google-cloud-telcoautomation/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/packages/google-cloud-telcoautomation/.eslintrc.json b/packages/google-cloud-telcoautomation/.eslintrc.json new file mode 100644 index 000000000000..3e8d97ccb390 --- /dev/null +++ b/packages/google-cloud-telcoautomation/.eslintrc.json @@ -0,0 +1,4 @@ +{ + "extends": "./node_modules/gts", + "root": true +} diff --git a/packages/google-cloud-telcoautomation/README.md b/packages/google-cloud-telcoautomation/README.md index edee53d8a015..5d0e33551daf 100644 --- a/packages/google-cloud-telcoautomation/README.md +++ b/packages/google-cloud-telcoautomation/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-telcoautomation/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-telcoautomation/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-telcoautomation/protos/protos.d.ts b/packages/google-cloud-telcoautomation/protos/protos.d.ts index 9c964b8d2a9f..2619d1c449cd 100644 --- a/packages/google-cloud-telcoautomation/protos/protos.d.ts +++ b/packages/google-cloud-telcoautomation/protos/protos.d.ts @@ -17142,6 +17142,9 @@ export namespace google { /** CommonLanguageSettings destinations */ destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); } /** Represents a CommonLanguageSettings. */ @@ -17159,6 +17162,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 @@ -17859,6 +17865,9 @@ export namespace google { /** PythonSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); } /** Represents a PythonSettings. */ @@ -17873,6 +17882,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 @@ -17951,6 +17963,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 { @@ -18277,6 +18401,9 @@ export namespace google { /** GoSettings common */ common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); } /** Represents a GoSettings. */ @@ -18291,6 +18418,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 @@ -18615,6 +18745,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, @@ -18996,6 +19229,7 @@ export namespace google { /** Edition enum. */ enum Edition { EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, EDITION_PROTO2 = 998, EDITION_PROTO3 = 999, EDITION_2023 = 1000, @@ -19026,6 +19260,9 @@ export namespace google { /** FileDescriptorProto weakDependency */ weakDependency?: (number[]|null); + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + /** FileDescriptorProto messageType */ messageType?: (google.protobuf.IDescriptorProto[]|null); @@ -19075,6 +19312,9 @@ export namespace google { /** FileDescriptorProto weakDependency. */ public weakDependency: number[]; + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + /** FileDescriptorProto messageType. */ public messageType: google.protobuf.IDescriptorProto[]; @@ -19209,6 +19449,9 @@ export namespace google { /** DescriptorProto reservedName */ reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents a DescriptorProto. */ @@ -19250,6 +19493,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 @@ -20097,6 +20343,9 @@ export namespace google { /** EnumDescriptorProto reservedName */ reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); } /** Represents an EnumDescriptorProto. */ @@ -20123,6 +20372,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 @@ -21057,6 +21309,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); @@ -21112,6 +21367,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[]; @@ -21332,6 +21590,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. */ @@ -21570,6 +21943,9 @@ export namespace google { /** EnumValueOptions debugRedact */ debugRedact?: (boolean|null); + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + /** EnumValueOptions uninterpretedOption */ uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); } @@ -21592,6 +21968,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[]; @@ -22184,6 +22563,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. */ @@ -22213,6 +22598,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 @@ -22335,6 +22726,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]{"code":"deadline_exceeded","msg":"operation timed out"}